Which user is login on which computer

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
alidar
Posts: 26
Joined: Wed Apr 11, 2018 7:15 am

Which user is login on which computer

Post by alidar »

Hello

Can we see that which user is login on which computer by nagios core?


Regards
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Which user is login on which computer

Post 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
Former Nagios employee
https://www.mcapra.com/
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: Which user is login on which computer

Post by cdienger »

Thanks for the assist, @mcapra!
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
alidar
Posts: 26
Joined: Wed Apr 11, 2018 7:15 am

Re: Which user is login on which computer

Post 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?
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Which user is login on which computer

Post 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.
Former Nagios employee
https://www.mcapra.com/
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: Which user is login on which computer

Post by tgriep »

Thanks @mcapra for the help. @alidar let us know if you have any further questions.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked