Page 1 of 1

check_snmp Return Codes Issue - Nagios not alerting

Posted: Fri Jun 24, 2016 8:02 am
by TheTomCAT
Hi all,

I am configuring Nagios to monitor a Brocade switch using snmp which is working using the following command

Code: Select all

define command{
command_name    check_brocade_port3
command_line    $USER1$/check_snmp -H 192.168.250.242 -o 1.3.6.1.2.1.2.2.1.8.3 -C winn -m ALL -t 60 | /usr/bin/cut -d'|' -f1
}
This is retuning the correct results;

SNMP CRITICAL - *down(2)*

But in Nagios the alert is not going CRITICAL and alerting. It remains green despite registering 'SNMP CRITICAL - *2* ' in the Status Information.

I am presuming this is something to do with the way in which snmp is passing return codes/arguments in the command but I don't seem to be able to get to the bottom of the issue. I have tried defining the critical alert with no luck so at the minute I am just stuck with the correct output, but no Nagios alert - rendering the entire thing pointless in monitoring terms.

Any help would be appreciated.

Thanks,
Tom

Re: check_snmp Return Codes Issue - Nagios not alerting

Posted: Fri Jun 24, 2016 8:19 am
by rhassing
I'm using the following to monitor the interface status:

Code: Select all

$USER1$/check_snmp -H 10.224.11.251 -o 1.3.6.1.2.1.2.2.1.8.1 -C public -r 1 -l "FW-01-eth1 interface status"
I think you should tell the check what output you expect:

Code: Select all

 -r, --ereg=REGEX
    Return OK state (for that OID) if extended regular expression REGEX matches
so the -r 1 is for status 1 (up) if the status returns something else then 1 it fails.

Re: check_snmp Return Codes Issue - Nagios not alerting

Posted: Fri Jun 24, 2016 9:37 am
by rkennedy
Thanks @rhassing!

To add to this, Nagios will change statuses based on the exit codes like you mentioned. 0 = ok, 1 = warning, 2 = critical, and 3 = unknown. The -r matching with the # output should work out as @rhassing mentioned.

Re: check_snmp Return Codes Issue - Nagios not alerting

Posted: Tue Jun 28, 2016 5:47 am
by TheTomCAT
-r has worked in this case and is now getting me the results I need. Is there a way to define the exit codes (0 = ok, 1 = warning, 2 = critical, and 3 = unknown) within the check_snmp command defined in Nagios?
rkennedy wrote:Thanks @rhassing!

To add to this, Nagios will change statuses based on the exit codes like you mentioned. 0 = ok, 1 = warning, 2 = critical, and 3 = unknown. The -r matching with the # output should work out as @rhassing mentioned.

Re: check_snmp Return Codes Issue - Nagios not alerting

Posted: Tue Jun 28, 2016 7:25 am
by rhassing
Is there a way to define the exit codes (0 = ok, 1 = warning, 2 = critical, and 3 = unknown) within the check_snmp command defined in Nagios?
I thought that was normal behavior, you should not have to change that.

Re: check_snmp Return Codes Issue - Nagios not alerting

Posted: Tue Jun 28, 2016 10:21 am
by rkennedy
rhassing wrote:
Is there a way to define the exit codes (0 = ok, 1 = warning, 2 = critical, and 3 = unknown) within the check_snmp command defined in Nagios?
I thought that was normal behavior, you should not have to change that.

@rhassing is correct, the exit codes are standardized at that and cannot be changed. Nagios will only accept those.

One way to flip exit codes is by using negate, which may work depending on what you're looking to accomplish. Take a look at this document - https://assets.nagios.com/downloads/nag ... ios-XI.pdf