I’ve written a plugin to check the number of messages in a particular IMAP inbox, and alert past a particular threshold. Don’t worry, I’m not expecting anyone to fix my code. What is troubling me is a problem with Nagios (v2.12) properly recognizing the exit status of my plugin. Here’s my code as executed by the nagios user on the command line:
-sh-3.2$ /usr/lib64/nagios/plugins/contrib/imap_inbox_check -w 10 -c 20 -a account01 -p password -s 10.12.1.51
CRITICAL: Cannot connect to 10.12.1.51 with account account01.
-sh-3.2$ echo $?
2
As you can see, the plugin exit with status 2, which should be interpreted as status critical. Here’s what I get from extended service information in Nagios:
Current Status: OK
Status Information: CRITICAL: Cannot connect to 10.12.1.51 with account account01.
Performance Data:
Current Attempt: 1/3
State Type: HARD
Last Check Type: ACTIVE
Last Check Time: 2011-03-21 17:02:35
Status Data Age: 0d 0h 1m 31s
Next Scheduled Active Check: 2011-03-21 17:07:35
Latency: 2.457 seconds
Check Duration: 0.110 seconds
Last State Change: 2011-03-21 17:02:35
Current State Duration: 0d 0h 1m 31s
Last Service Notification: N/A
Current Notification Number: 0
Is This Service Flapping? N/A
Percent State Change: N/A
In Scheduled Downtime? NO
Last Update: 2011-03-21 17:04:03
Note the status OK. Any advice/help is greatly appreciated.