You must write your own script.
In this script, you can use the following options of the check_snmp plugin:
-s, --string=STRING: Return OK state (for that OID) if STRING is an exact match
-r, --ereg=REGEX: Return OK state (for that OID) if extended regular expression REGEX matches
-R, --eregi=REGEX: Return OK state (for that OID) if case-insensitive extended REGEX matches
--invert-search: Invert search result (CRITICAL if found)
For example, I have to verify the state of 3 hdd on my server, with a specified OID. This OID return the string "Normal" when all is ok and "Critical" when there is a problem, so my command is:
./check_snmp -H <@IP> -C <community> -o .1.3.6.1.4.1.2.3.51.3.1.12.2.1.3.0 --invert-search -r "Critical" -o .1.3.6.1.4.1.2.3.51.3.1.12.2.1.3.1 -r "Critical" -o .1.3.6.1.4.1.2.3.51.3.1.12.2.1.3.2 -r "Critical" -o -l "Drive 0" -l "Drive 1" -l "Drive 2" -l "Drive 3"
It will return when all is ok:
SNMP OK - Drive 0 "Normal" Drive 1 "Normal" Drive 2 "Normal" Drive 3 "Normal" |
and when there is a problem:
SNMP CRITICAL - Drive 0 "Normal" Drive 1 "Normal" Drive 2 "Normal" Drive 3 *"Critical"*
If you want to have numbers instead strings, you must modify the results your script will send to nagios. In my case, I wanted a text with the normal exit of check_snmp, and the value 1 for Normal state and 0 for Critical value for perfdata. So in my script I did like this:
...
test="$(/usr/lib/nagios/plugins/check_snmp -H <snip> -C <snip> --invert-search -o .1.3.6.1.4.1.2.3.51.3.1.12.2.1.3.$i -r Critical)"
if (echo $test | grep -q Critical); then
#echo "Drive $i" = 0
texte+="Drive_$i CRITICAL, "
perfdata+="Drive_$i=0 "
crit=1
else
#echo "Drive $i" = 1
texte+="Drive_$i Normal, "
perfdata+="Drive_$i=1 "
...
if [ $crit = 1 ]
then
resultat="CRITICAL: "
result_code=2
else
resultat="OK: "
result_code=0
fi
resultat+="$texte|$perfdata"
echo $resultat
exit $result_code
The exit of your script will be:
CRITICAL: Drive_0 Normal, Drive_1 Normal, Drive_2 Normal, Drive_3
Normal, Drive_4 Normal, Drive_5 Normal, Drive_6 Normal, Drive_7 Normal,
Drive_8 CRITICAL, Drive_9 CRITICAL, Drive_10 CRITICAL, |Drive_0=1
Drive_1=1
Drive_2=1 Drive_3=1 Drive_4=1 Drive_5=1 Drive_6=1 Drive_7=1 Drive_8=0
Drive_9=0 Drive_10=0
With at left of the "|" the text will appear in nagios, ahd at the right the values for perfdata by disk.
nagios define the state of the service depending on the value returned by the function exit