Page 1 of 1

check_nrpe - NSClient - Exit Codes always showing 'Warning'

Posted: Mon Jun 18, 2012 6:34 am
by sixarm
Hi,

I've just been playing with a few PowerShell scripts for my Exchange environment and these are working really well.

Sadly, no matter if I exit the script with code 1 or code 2 it always shows as 'Warning' within Nagios. I also manually tested a code 3 exit and this also showed up as 'Warning'.

Any ideas?

Re: check_nrpe - NSClient - Exit Codes always showing 'Warni

Posted: Mon Jun 18, 2012 10:39 am
by agriffin
Are you sure it says warning when you use exit code 2? It should say critical instead. To get an OK state, exit with code 0.

Re: check_nrpe - NSClient - Exit Codes always showing 'Warni

Posted: Tue Jun 19, 2012 3:58 am
by sixarm
Sadly yes.

If you look at the screenshot the IF statement involved within the PowerShell script adds "CRITICAL:" to the text and sets the exit code to 2. You can clearly see that the "CRITICAL:" part is being returned within the text, however as you can see Nagios is only showing WARNING, not CRITICAL.

Could this be something to do with the NSClient++ settings? Is there any way that I can debug this at all?

Re: check_nrpe - NSClient - Exit Codes always showing 'Warni

Posted: Tue Jun 19, 2012 3:37 pm
by agriffin
That's pretty weird. Would it be possible to post the script you're running?

Re: check_nrpe - NSClient - Exit Codes always showing 'Warni

Posted: Thu Jun 21, 2012 3:28 am
by sixarm
Of course, here it is. - http://pastebin.com/Pahxh6Qb

It's a slightly modified version of this plugin.

All I've modified is the output text and the thresholds.

Re: check_nrpe - NSClient - Exit Codes always showing 'Warni

Posted: Mon Jun 25, 2012 9:52 am
by yancy
Hi sixarm,

Can you also post the external script command your using in NSClient++. Should be located in NSC.ini and look like this:
cmd /c echo scripts\%SCRIPT% %ARGS%; exit($lastexitcode) | powershell.exe -command -

If you run the powershell script from powershell, and you then run "echo $lastexitcode" is that exit code being interpreted correctly?

Regards,

Re: check_nrpe - NSClient - Exit Codes always showing 'Warni

Posted: Mon Jun 25, 2012 10:01 am
by sixarm
Hi yancy,

Thanks for the reply.

Below is what I have within NSC.ini

Code: Select all

check_exqueue=cmd /c echo scripts\ExchangeQueueHealth.ps1 | powershell.exe -command -
I don't have exit parameters in there so I'm guessing this could be my problem. If I were to change the line within NSC.ini to the below would that solve this issue?

Code: Select all

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

Re: check_nrpe - NSClient - Exit Codes always showing 'Warni

Posted: Mon Jun 25, 2012 10:56 am
by sixarm
Thanks yancy.

I can confirm that Nagios is now reporting 'Warning' and 'Critical' states from the Powershell script exit codes.

Re: check_nrpe - NSClient - Exit Codes always showing 'Warni

Posted: Mon Jun 25, 2012 3:45 pm
by agriffin
Glad you were able to get it working!