Page 1 of 1

NSclient + Powershell + Check_NRPE Timeout

Posted: Fri May 24, 2019 1:24 am
by dimagohsc
Hello there!

I'm trying to configure a Windows Server 2012 to be able to run a script by nsclient.

1 - I have nsclient already installed, see the output:
root@nagios ~ # /usr/lib64/nagios/plugins/check_nrpe -H 10.10.10.10 -p 5666
I (0.5.2.39 2018-02-04) seem to be doing fine...

2 - When I try to run the same command above, using the - c "command" it does not work. I have tried everything I know!
root@nagios ~ # /usr/lib64/nagios/plugins/check_nrpe -H 10.10.10.10 -p 5666 -c check_vmware_snapshots -t 50 (-t 70, no way)
CHECK_NRPE: Socket timeout after 50 seconds.

3 - When I run my script in the local nsclient terminal, it works:
powershell.exe -PSConsoleFile "c:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\vim.psc1" "& 'C:\Program Files\NSClient++\scripts\check_vmware_snapshots.ps1'"
Critical - 1 snapshots older than 5 days - @{VM=SERVER01}

I'm going to share my powershell script and my nsclient configuration. Note that my nsclient.ini has many conf I tried.

powershell script
check_vmware_snapshots.txt
(1.3 KiB) Downloaded 242 times
nsclient config
nsclient.txt
(12.56 KiB) Downloaded 283 times
If I use this command: "check_vmware_snapshots = cmd /c echo hello" in that script section and run in my nagios server, I do see the "hello".

How should I add that command into my nsclient.ini to get this working?

Please, any help is really welcome :)

Thanks!

Re: NSclient + Powershell + Check_NRPE Timeout

Posted: Fri May 24, 2019 2:47 pm
by tgriep
The command in the nsclient.ini file may not be formatted correctly so change this line from

Code: Select all

ps1 = cmd /c echo If (-Not (Test-Path "scripts\%SCRIPT%") ) { Write-Host "UNKNOWN: Script `"%SCRIPT%`" not found."; exit(3) }; scripts\%SCRIPT% $ARGS$; exit($lastexitcode) | powershell.exe /noprofile -command -
to

Code: Select all

ps1 = cmd /c echo scripts\\%SCRIPT% %ARGS%; exit($lastexitcode) | powershell.exe -command -

Then change this line from

Code: Select all

check_vmware_snapshots = powershell.exe -PSConsoleFile "c:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\vim.psc1" "& 'C:\Program Files\NSClient++\scripts\check_vmware_snapshots.ps1'" ; exit($lastexitcode)
to

Code: Select all

check_vmware_snapshots = cmd /c echo "c:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\vim.psc1" "& 'C:\Program Files\NSClient++\scripts\check_vmware_snapshots.ps1'"; exit ($lastexitcode) | powershell.exe -noprofile -executionpolicy bypass -command -

Save the file and restart NSClient++.

If you still get the error, get the nsclient.log file from the server and post ti here so we can view the errors.

Re: NSclient + Powershell + Check_NRPE Timeout

Posted: Fri May 24, 2019 3:48 pm
by dimagohsc
hey tgriep!

I finally have it working!

thanks for your help, really appreciate that.

Diego

Re: NSclient + Powershell + Check_NRPE Timeout

Posted: Tue May 28, 2019 6:44 am
by scottwilkerson
dimagohsc wrote:hey tgriep!

I finally have it working!

thanks for your help, really appreciate that.

Diego
Great!

Locking thread