Page 1 of 2

XI for Windows 2008 R2: how to check specific account logon

Posted: Fri Feb 12, 2016 3:30 pm
by dlukinski
Hello XI support

Please advice how to check if specific account is logged on to the server (and remain logged on)
- so that we monitor and alert if account logged off (some application account)
- Windows 2008 R2

/Dimitri

Re: XI for Windows 2008 R2: how to check specific account lo

Posted: Mon Feb 15, 2016 12:22 pm
by lmiltchev
Are you talking about monitoring a service or a process? Can you give us a specific example?

Re: XI for Windows 2008 R2: how to check specific account lo

Posted: Tue Feb 16, 2016 1:23 pm
by dlukinski
lmiltchev wrote:Are you talking about monitoring a service or a process? Can you give us a specific example?
Monitor account (user) XYZ logged to the server, alert when logs off (some applications require this kind to "running" RDP session by certain account

Re: XI for Windows 2008 R2: how to check specific account lo

Posted: Tue Feb 16, 2016 2:55 pm
by rkennedy
I found this script, would it work for you? https://exchange.nagios.org/directory/P ... er/details

Re: XI for Windows 2008 R2: how to check specific account lo

Posted: Tue Mar 01, 2016 4:21 pm
by dlukinski
rkennedy wrote:I found this script, would it work for you? https://exchange.nagios.org/directory/P ... er/details

Partially. Followed instructions

ini looks this way:
[/settings/external scripts/scripts]
check_user=cmd /c echo scripts\\check_user.ps1 ZZTP-APL01 RES svc_ZZZsrv1; exit $LastExitCode | powershell.exe -command-


XI end shows this:
OK Missing expression after unary operator '-'.
At line:1 char:2

+ - <<<< command-

+ CategoryInfo : ParserError: (-:String) [], ParentContainsErrorR

ecordException

+ FullyQualifiedErrorId : MissingExpressionAfterOperator

Re: XI for Windows 2008 R2: how to check specific account lo

Posted: Tue Mar 01, 2016 4:28 pm
by rkennedy
Can you try changing it to be (space after command but before the -) -

Code: Select all

check_user=cmd /c echo scripts\\check_user.ps1 ZZTP-APL01 RES svc_ZZZsrv1; exit $LastExitCode | powershell.exe -command -
Let us know if that helps.

Re: XI for Windows 2008 R2: how to check specific account lo

Posted: Thu Mar 03, 2016 4:08 pm
by dlukinski
rkennedy wrote:Can you try changing it to be (space after command but before the -) -

Code: Select all

check_user=cmd /c echo scripts\\check_user.ps1 ZZTP-APL01 RES svc_ZZZsrv1; exit $LastExitCode | powershell.exe -command -
Let us know if that helps.
This is what I get when trying to "test" from XI GUI:

COMMAND: /usr/local/nagios/libexec/check_nrpe -H 10.72.129.49 -t 30 -c check_user
OUTPUT: File C:\Program Files\NSClient++\scripts\check_user.ps1 cannot be loaded becaus
e the execution of scripts is disabled on this system. Please see "get-help abo
ut_signing" for more details.
At line:1 char:24
+ scripts\\check_user.ps1 <<<< DEHP-APL01 RES svc_stahlsrv1; exit $LastExitCod

INI file attached.
e
+ CategoryInfo : NotSpecified: (:) [], PSSecurityException
+ FullyQualifiedErrorId : RuntimeException

Re: XI for Windows 2008 R2: how to check specific account lo

Posted: Thu Mar 03, 2016 5:48 pm
by lmiltchev
OUTPUT: File C:\Program Files\NSClient++\scripts\check_user.ps1 cannot be loaded becaus
e the execution of scripts is disabled on this system. Please see "get-help abo
ut_signing" for more details.
Are you allowed to run PS scrips on this system? Can you open a powershell terminal, type the following command, and show the output?

Code: Select all

Get-ExecutionPolicy

Re: XI for Windows 2008 R2: how to check specific account lo

Posted: Fri Mar 04, 2016 10:18 am
by dlukinski
lmiltchev wrote:
OUTPUT: File C:\Program Files\NSClient++\scripts\check_user.ps1 cannot be loaded becaus
e the execution of scripts is disabled on this system. Please see "get-help abo
ut_signing" for more details.
Are you allowed to run PS scrips on this system? Can you open a powershell terminal, type the following command, and show the output?

Code: Select all

Get-ExecutionPolicy
You right: restricted

Re: XI for Windows 2008 R2: how to check specific account lo

Posted: Fri Mar 04, 2016 12:53 pm
by hsmith
Is that something you're going to be able to fix?