Search Exchange

Search All Sites

Nagios Live Webinars

Let our experts show you how Nagios can help your organization.

Contact Us

Phone: 1-888-NAGIOS-1
Email: sales@nagios.com

Login

Remember Me

Directory Tree

Check logged on user

Current Version
2.0
Last Release Date
2015-08-26
Compatible With
  • Nagios 4.x
Owner
License
GPL
Hits
26903
Files:
FileDescription
check_user.ps1check_user.ps1
Nagios CSP

Meet The New Nagios Core Services Platform

Built on over 25 years of monitoring experience, the Nagios Core Services Platform provides insightful monitoring dashboards, time-saving monitoring wizards, and unmatched ease of use. Use it for free indefinitely.

Monitoring Made Magically Better

  • Nagios Core on Overdrive
  • Powerful Monitoring Dashboards
  • Time-Saving Configuration Wizards
  • Open Source Powered Monitoring On Steroids
  • And So Much More!
Check logged on user
Checks if a specific user is logged on to a specific system.
This script checks if a specific user is logged on to a specific system. The script will cath any error.
Status is OK if the user is logged on, and CRITICAL if not.
The computername, name of the domain and username are variable, so the script will accept any supplied value as an argument.

---------
Syntax:
---------

get_user.ps1 computername domain user

- For a remote system, the parameter computername can be a hostname, or an IP address. For the local machine, you can use localhost or a dot (.) as valid values.
- The parameter domain is the name of the domain (if the user is a domain user), or the computername (for a local user).
- The parameter user is the user logon name.

--------
Notes:
--------

- PowerShell scripts must be allowed to run on the target computer (PowerShell Script Execution Policy).
- Disconnected user sessions are recognized as logged on users. Which in fact is correct, because with a disconnected session, the user is still logged on to the system.

----------------------------
Installation instructions:
----------------------------

- Put the Powershell script in the C:\Program Files\NSClient++\Scripts directory.
- In the nsclient.ini file, in the section [/settings/external scripts/scripts], add the following line:
check_user=cmd /c echo scripts\\check_user.ps1 computername domain user; exit $LastExitCode | powershell.exe -command -
- Restart the NSClient
- On the Nagios server, create a service with the following check command:
check_command check_nrpe!check_user!
- Restart Nagios
Reviews (1)
It works fine, we just use the check_nrpe command with user_logon as a parameter.

Also we changed the variables to the following format:
$hostname=some.domain.com
$domain=domain.com
$user=domainuser

If we left the variables as they where ([string]$param,]) we would get a syntax error.

And last: . as a hostname does not work for us. Nor does localhost. FQDN works fine. Might have something to do with checking a domain user/machine.

We have a working check, so happy campers. Thanks!