Issue warnings with text output of check_snmp in Nagios

check-snmpnagios

I'm trying to configure Icinga to query the SMART status of the hard drives loaded into a storage array I'm configuring.

The issue I've run into is the response from the array when querying the OID of a drive is text, and not a number.

./check_snmp -H 10.0.10.17 -P 2c -C public -o .1.3.6.1.4.1.24681.1.2.11.1.7.1
SNMP OK - "GOOD" |

I'm used to working with numbers rather than strings when dealing with output of check_snmp. Does anyone know how I can create a critical or warning notification when anything other than the output GOOD is returned?

Best Answer

You certainly already know that Nagios needs a number (0,1,2,3) as a return status code from the command launched.

if $? for the check_snmp command always returns 0, my advice would be to write your own check adding pipe and grep to the check_snmp command, something like :

./check_snmp -H 10.0.10.17 -P 2c -C public -o .1.3.6.1.4.1.24681.1.2.11.1.7.1 | grep GOOD

This will return 0 (OK) if word GOOD is found within the output, otherwise it will return 1 (Warning).