NSclient + Powershell + Check_NRPE Timeout

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
dimagohsc
Posts: 2
Joined: Fri May 24, 2019 12:59 am

NSclient + Powershell + Check_NRPE Timeout

Post 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 243 times
nsclient config
nsclient.txt
(12.56 KiB) Downloaded 284 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!
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: NSclient + Powershell + Check_NRPE Timeout

Post 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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
dimagohsc
Posts: 2
Joined: Fri May 24, 2019 12:59 am

Re: NSclient + Powershell + Check_NRPE Timeout

Post by dimagohsc »

hey tgriep!

I finally have it working!

thanks for your help, really appreciate that.

Diego
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: NSclient + Powershell + Check_NRPE Timeout

Post by scottwilkerson »

dimagohsc wrote:hey tgriep!

I finally have it working!

thanks for your help, really appreciate that.

Diego
Great!

Locking thread
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked