:!: check_snmp always OK status

I have a Nagios 3.2.3 installation with standard nagios plugins 1.4.15 in a debian box.

I wan to check an UPS with de check_snmp plugin. I must check the returning string with the -R parameter; if string returned contains “Test OK” then must be OK status, or CRITICAL if doesn’t. But in all cases, Nagios always report me a OK status?!?

So I did some tests, all seems to be OK, but in Nagios service status always is green with “Current Status: OK for (…”

nagios:~# /usr/lib/nagios/plugins/check_snmp -H x.x.x.x -m ‘/usr/share/snmp/mib2c-data’ -P 2c -C public -p 161 -o .1.3.6.1.2.1.33.1.7.4.0 -r “Test KO” -v ; echo “exit value” $?
/usr/bin/snmpget -t 1 -r 5 -m /usr/share/snmp/mib2c-data -v 2c [authpriv] x.x.x.x:161 .1.3.6.1.2.1.33.1.7.4.0
iso.3.6.1.2.1.33.1.7.4.0 = STRING: "Test OK. Holdtime: 0.00."
SNMP CRITICAL - “Test OK. Holdtime: 0.00.” |
exit value 2

nagios:~# /usr/lib/nagios/plugins/check_snmp -H x.x.x.x -m ‘/usr/share/snmp/mib2c-data’ -P 2c -C public -p 161 -o .1.3.6.1.2.1.33.1.7.4.0 -r “Test OK” -v ; echo “exit value” $?
/usr/bin/snmpget -t 1 -r 5 -m /usr/share/snmp/mib2c-data -v 2c [authpriv] x.x.x.x:161 .1.3.6.1.2.1.33.1.7.4.0
iso.3.6.1.2.1.33.1.7.4.0 = STRING: "Test OK. Holdtime: 0.00."
SNMP OK - “Test OK. Holdtime: 0.00.” |
exit value 0

I don’t have any more clues with this plugin. Other plugins I used were pretty easy to use.

Thanks

Julian.

could you please post the service check and check commands ?

Thanks you in advance for you interest.

Here are my definitions. I tested the -r with “Test OK” and “Test KO”, both with OK status reported.

CHECK COMMAND

define command{
command_name check_snmp_sin_alertas
command_line $USER1$/check_snmp -H $HOSTADDRESS$ -P $ARG1$ -C $ARG2$ -p $ARG3$ -o $ARG4$ -m ‘/usr/share/snmp/mib2c-data/’ $ARG5$
}

CHECK SERVICE

define service {
host_name UPS
service_description Estado_Ultimo_Test
check_command check_snmp_sin_alertas!2c!public!161!1.3.6.1.2.1.33.1.7.4.0!-r “Test OK” | sed 's/iso.3.6.1.2.1.33.1.7.4.0/Ultimo_Test/g’
use generic-service
action_url /nagiosgraph/cgi-bin/show.cgi?host=$HOSTNAME$&service=$SERVICEDESC$
notification_interval 0 ; set > 0 if you want to be renotified
check_interval 1440
retry_interval 1
}

-r “Test OK” | sed ‘s/iso.3.6.1.2.1.33.1.7.4.0/Ultimo_Test/g’

i dont’ think that’s a valid argument… try removing the pipe and sed part and see how it works.

Hi Luca

You hit! I Have multiple commands definitions with last argument acting as a extra free argument. In many other commands runs ok, that confused me. I used sed to replace perf. data label with some more human readable.

So may last question is… Can check_snmp get OID names within a directory full of MIBs? If perf. data return the OID name I no need to use sed command and let definition more clear. I think that -m parameter did it, but I’m not sure!

Thanks very much.

Julian.

that should be the -m option if you get the right mib to load…
but if you have the right OID the mib is useless, you just want the result, and not loading the mib could makje the check a bit faster and unload the server.