check_snmp Return Codes Issue - Nagios not alerting

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
TheTomCAT
Posts: 8
Joined: Tue Jun 21, 2016 3:03 am
Location: England

check_snmp Return Codes Issue - Nagios not alerting

Post 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
User avatar
rhassing
Posts: 416
Joined: Sat Oct 05, 2013 10:29 pm
Location: Netherlands

Re: check_snmp Return Codes Issue - Nagios not alerting

Post 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.
Rob Hassing
Image
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: check_snmp Return Codes Issue - Nagios not alerting

Post 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.
Former Nagios Employee
TheTomCAT
Posts: 8
Joined: Tue Jun 21, 2016 3:03 am
Location: England

Re: check_snmp Return Codes Issue - Nagios not alerting

Post 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.
User avatar
rhassing
Posts: 416
Joined: Sat Oct 05, 2013 10:29 pm
Location: Netherlands

Re: check_snmp Return Codes Issue - Nagios not alerting

Post 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.
Rob Hassing
Image
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: check_snmp Return Codes Issue - Nagios not alerting

Post 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
Former Nagios Employee
Locked