Page 1 of 1
Which user is login on which computer
Posted: Mon Jun 11, 2018 2:56 am
by alidar
Hello
Can we see that which user is login on which computer by nagios core?
Regards
Re: Which user is login on which computer
Posted: Mon Jun 11, 2018 6:53 am
by mcapra
Sure, but the actual implementation would depend on the authentication method being used (sometimes) as well as the operating system itself (all the time).
Here's an older post I made where I do a Windows-based "logged in users" check via Powershell using and older
NSClient++ version as the agent:
https://support.nagios.com/forum/viewto ... 58#p191894
You could expand on that Powershell following the
nagios plugin development guidelines if you wanted richer output.
There's a few different options available on the Nagios Exchange as well:
https://exchange.nagios.org/index.php?o ... 0on%20user
Re: Which user is login on which computer
Posted: Mon Jun 11, 2018 3:20 pm
by cdienger
Thanks for the assist,
@mcapra!
Re: Which user is login on which computer
Posted: Tue Jun 12, 2018 1:41 am
by alidar
In old post, I copied this script. Can you tell me where I will put this script.
The following powershell script (I named it check_users.ps1) worked against my Windows 7 machine:
Code: Select all
$computername = 'localhost'
$user = Get-WMIObject Win32_Process -filter 'name="explorer.exe"' -computername $ComputerName |
ForEach-Object { $owner = $_.GetOwner(); '{0}\{1}' -f $owner.Domain, $owner.User } |
Sort-Object | Get-Unique
if(!$user) {Write-Host ""}
else {Write-Host $user}
My NSClient++ (0.4.x) command configuration:
Code: Select all
[/settings/external scripts/scripts]
check_users = cmd /c echo scripts\check_users.ps1; exit($lastexitcode) | powershell.exe -command -
I am using NCPA client. How I can use on NCPA?
Re: Which user is login on which computer
Posted: Tue Jun 12, 2018 6:49 am
by mcapra
Here's the official documentation for using custom scripts/plugins with NCPA:
https://support.nagios.com/kb/article/n ... a-722.html
It has a section which includes a sample Powershell script. Let us know if some part of that documentation is unclear or isn't working correctly.
Re: Which user is login on which computer
Posted: Tue Jun 12, 2018 3:42 pm
by tgriep
Thanks
@mcapra for the help.
@alidar let us know if you have any further questions.