Checks if a specific user is logged on to a Windows system.

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
Aldo Lanfranconi
Posts: 22
Joined: Fri Jan 29, 2021 12:06 pm

Checks if a specific user is logged on to a Windows system.

Post by Aldo Lanfranconi »

Hello, I would like to chek if a specific user is logged on to a windows server.

I have Nagios 5.8.6
I use NCPA client

I have found this topic on Nagios Exchange:
https://exchange.nagios.org/directory/P ... er/details
but this plugin seems to be developed to work with NSCLIENT++

How can I make it work with NCPA? or are there any other similar plugin or builtin check on NCPA?

Thanks in advance.
gsmith
Posts: 1253
Joined: Tue Mar 02, 2021 11:15 am

Re: Checks if a specific user is logged on to a Windows syst

Post by gsmith »

hi

What version of Windows server are you running?

Thanks
gsmith
Posts: 1253
Joined: Tue Mar 02, 2021 11:15 am

Re: Checks if a specific user is logged on to a Windows syst

Post by gsmith »

Hi

Here is what I came up with, it's rough but works.

Create a file called check_user.ps1 and put it in C:\Program Files (x86)\Nagios\NCPA\plugins on the remote Windows machine.

check_user.ps1:

Code: Select all

$exitcode=2
if (((quser) | Out-String).contains($Args[0])) {
  $exitcode=0
}
 
Write-Host("User checked was: " + $Args[0])
#Write-Host($exitcode)
exit $exitcode
In Nagios set it up as shown, with the $ARG1$ shown:
-t 'gjstoken' -P 5693 -M 'plugins/check_user.ps1' -a 'administrator'
check_user.jpg
Thanks
You do not have the required permissions to view the files attached to this post.
Aldo Lanfranconi
Posts: 22
Joined: Fri Jan 29, 2021 12:06 pm

Re: Checks if a specific user is logged on to a Windows syst

Post by Aldo Lanfranconi »

Awsome!!, It works like a charm!, Thanks a lot!
gsmith
Posts: 1253
Joined: Tue Mar 02, 2021 11:15 am

Re: Checks if a specific user is logged on to a Windows syst

Post by gsmith »

Hi

Glad it's working for you.

Have a good day!
Locked