Page 3 of 6

Re: Not able to Run Powershell Script using NRPE

Posted: Wed Mar 23, 2016 5:09 pm
by WillemDH
Try again like this:

Code: Select all

./check_nrpe -H 192.168.30.64 -t 60 -c topcpu -a 'vm-restore-cy1 memwarn 85 memcrit 95'

Re: Not able to Run Powershell Script using NRPE

Posted: Wed Mar 23, 2016 5:19 pm
by CloudOps
WillemDH wrote:Try again like this:

Code: Select all

./check_nrpe -H 192.168.30.64 -t 60 -c topcpu -a 'vm-restore-cy1 memwarn 85 memcrit 95'
if i use -a then i am getting this error :

[root@VM-NAGIOSXI-TEST libexec]# ./check_nrpe -H 192.168.30.64 -c topcpu -a 'vm-restore-cy1 memwarn 85 memcrit 95'
Arguments not allowed see nsclient.log for details
[root@VM-NAGIOSXI-TEST libexec]#

and if i try without -t 300 then i am getting socket timeout after 10 seconds :

[root@VM-NAGIOSXI-TEST libexec]# ./check_nrpe -H 192.168.30.64 -c topcpu "vm-restore-cy1 memwarn 85 memcrit 95"
CHECK_NRPE: Socket timeout after 10 seconds.

and if i use -t 300 then same error :

[root@VM-NAGIOSXI-TEST libexec]# ./check_nrpe -H 192.168.30.64 -c topcpu 'vm-restore-cy1 memwarn 85 memcrit 95' -t 300
CHECK_NRPE: Received 0 bytes from daemon. Check the remote server logs for error messages.

i am attaching my nsclinet configuration file.

Re: Not able to Run Powershell Script using NRPE

Posted: Thu Mar 24, 2016 2:23 am
by WillemDH
You need this:

Code: Select all

[/settings/external scripts]
allow arguments = true
allow nasty characters = true

Re: Not able to Run Powershell Script using NRPE

Posted: Thu Mar 24, 2016 8:43 am
by CloudOps
WillemDH wrote:You need this:

Code: Select all

[/settings/external scripts]
allow arguments = true
allow nasty characters = true
I have added the above lines, but i am not getting the outpu, still getting the same error :

2016-03-24 06:38:17: error:c:\source\nscp\service\NSClient++.cpp:906: Failed to execute command
2016-03-24 06:40:49: error:c:\source\nscp\include\socket/connection.hpp:149: Failed to send data: The file handle supplied is not valid

Thanks

Re: Not able to Run Powershell Script using NRPE

Posted: Thu Mar 24, 2016 9:34 am
by lmiltchev
Did you copy the script from "C:\Program Files\NSClient++\plugins" back to "C:\Program Files\NSClient++\scripts" directory?

Also, you allow arguments under the NRPE section but they need to be allowed under the external scripts section, too. In my nsclient.ini, I have:

Code: Select all

[/settings/external scripts]
allow arguments = 1
allow nasty characters=1
You may need to add this section, and restart NSClient++ service.

BTW, if you want to load all of the defaults in the nsclient.ini, open CMD prompt, and run:

Code: Select all

cd "C:\Program Files\NSClient++
nscp settings --generate --add-defaults --load-all

Re: Not able to Run Powershell Script using NRPE

Posted: Thu Mar 24, 2016 10:22 am
by CloudOps
lmiltchev wrote:Did you copy the script from "C:\Program Files\NSClient++\plugins" back to "C:\Program Files\NSClient++\scripts" directory?

Also, you allow arguments under the NRPE section but they need to be allowed under the external scripts section, too. In my nsclient.ini, I have:

Code: Select all

[/settings/external scripts]
allow arguments = 1
allow nasty characters=1
You may need to add this section, and restart NSClient++ service.

BTW, if you want to load all of the defaults in the nsclient.ini, open CMD prompt, and run:

Code: Select all

cd "C:\Program Files\NSClient++
nscp settings --generate --add-defaults --load-all
I have already copied files to Script folder , added lines to nsclinet. but still issue is there.is there anything i am missing??

Re: Not able to Run Powershell Script using NRPE

Posted: Thu Mar 24, 2016 11:35 am
by lmiltchev
Change your command in the nsclient.ini from this:

Code: Select all

topcpu = cmd /c scripts\resourcecheck.ps1 $ARG1$; exit $LastExitcode | powershell.exe -command
to this:

Code: Select all

topcpu = cmd /c echo scripts\resourcecheck.ps1 $ARG1$; exit $LastExitcode | powershell.exe -command -
Note: Add "echo" before scripts, and "-" after "command" (with a space between them).

Restart NSClient++ service.

Do you see any errors when you run the check now?

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H 192.168.30.64 -t 60 -c topcpu -a 'vm-restore-cy1 -memwarn 85 -memcrit 95'

Re: Not able to Run Powershell Script using NRPE

Posted: Thu Mar 24, 2016 1:32 pm
by CloudOps
lmiltchev wrote:Change your command in the nsclient.ini from this:

Code: Select all

topcpu = cmd /c scripts\resourcecheck.ps1 $ARG1$; exit $LastExitcode | powershell.exe -command
to this:

Code: Select all

topcpu = cmd /c echo scripts\resourcecheck.ps1 $ARG1$; exit $LastExitcode | powershell.exe -command -
Note: Add "echo" before scripts, and "-" after "command" (with a space between them).

Restart NSClient++ service.

Do you see any errors when you run the check now?

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H 192.168.30.64 -t 60 -c topcpu -a 'vm-restore-cy1 -memwarn 85 -memcrit 95'
when i am running this command :
[root@VM-NAGIOSXI-TEST libexec]# ./check_nrpe -H 192.168.30.64 -c topcpu "vm-restore-cy1 memwarn 85 memcrit 95" -t 120
Get-WmiObject : The RPC server is unavailable. (Exception from HRESULT: 0x80070
6BA)
At C:\Program Files\NSClient++\scripts\resourcecheck.ps1:11 char:27
+ $TotalRAM = (get-WMIObject <<<< win32_operatingsystem -computername $servern
ame
[root@VM-NAGIOSXI-TEST libexec]# ./check_nrpe -H 192.168.30.64 -c topcpu "vm-restore-cy1 memwarn 85 memcrit 95" -t 120

But ther is no issue running the command locally. output attached.

Re: Not able to Run Powershell Script using NRPE

Posted: Thu Mar 24, 2016 2:04 pm
by lmiltchev
Can you copy/paste this command to your putty window and show the output of it?

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H 192.168.30.64 -c topcpu -a 'vm-restore-cy1 -memwarn 85 -memcrit 95'

Re: Not able to Run Powershell Script using NRPE

Posted: Thu Mar 24, 2016 2:45 pm
by CloudOps
lmiltchev wrote:Can you copy/paste this command to your putty window and show the output of it?

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H 192.168.30.64 -c topcpu -a 'vm-restore-cy1 -memwarn 85 -memcrit 95'
Here is the output which you have asked :

[root@VM-NAGIOSXI-TEST libexec]# ./check_nrpe -H 192.168.30.64 -c topcpu -a 'vm-restore-cy1.hosting.metricstream.com -memwarn 85 -memcrit 95'
CHECK_NRPE: Socket timeout after 10 seconds.

[root@VM-NAGIOSXI-TEST libexec]# ./check_nrpe -H 192.168.30.64 -t 60 -c topcpu -a 'vm-restore-cy1 -memwarn 85 -memcrit 95'
CHECK_NRPE: Received 0 bytes from daemon. Check the remote server logs for error messages.