check_nrpe - NSClient - Exit Codes always showing 'Warning'

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
sixarm
Posts: 12
Joined: Sat Apr 07, 2012 5:05 am

check_nrpe - NSClient - Exit Codes always showing 'Warning'

Post 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?
agriffin
Posts: 876
Joined: Mon May 09, 2011 9:36 am

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

Post 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.
sixarm
Posts: 12
Joined: Sat Apr 07, 2012 5:05 am

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

Post 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?
Attachments
Nagios.JPG
agriffin
Posts: 876
Joined: Mon May 09, 2011 9:36 am

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

Post by agriffin »

That's pretty weird. Would it be possible to post the script you're running?
sixarm
Posts: 12
Joined: Sat Apr 07, 2012 5:05 am

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

Post 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.
yancy
Posts: 523
Joined: Thu Oct 06, 2011 10:12 am

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

Post 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,
sixarm
Posts: 12
Joined: Sat Apr 07, 2012 5:05 am

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

Post 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 -
sixarm
Posts: 12
Joined: Sat Apr 07, 2012 5:05 am

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

Post by sixarm »

Thanks yancy.

I can confirm that Nagios is now reporting 'Warning' and 'Critical' states from the Powershell script exit codes.
agriffin
Posts: 876
Joined: Mon May 09, 2011 9:36 am

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

Post by agriffin »

Glad you were able to get it working!
Locked