[SOLVED]check_snmp : string match question


#1

Hi

OK, I’m using an ooooooooooooooold nagios version (debian-sarge-that-is-working-fine-so-we-don’t-take-the-risk-to-break-it…) :
nagios 1.3.

I’m trying to monitor an OID on a box that should return me “All is OK”.
In /etc/nagios-plugins/config/snmp.cfg, I have this (note the “-s”, for which I can’t find much example on the web…) :

/usr/lib/nagios/plugins/check_snmp -H $HOSTADDRESS$ -C $ARG1$ -o .1.2.3.4.5.6 -s "All is OK."

But in the nagios page, it tells me CRITICAL, although it DOES return the right message :

tcpdump shows me something strange, it add at the end of the message a “^J” : I tryed to put it in the “-s” string, but doesn’t work either…

09:46:40.693261 IP (tos 0x0, ttl  63, id 4262, offset 0, flags [none], length: 108) XXX.XXX.XXX.XXX.snmp > YYY.YYY.YYY.YYY.50705: [udp sum ok]  { SNMPv1 { GetResponse(65) R=808881425  E:789.1.5.7.2.0="All is OK^J" } }

If someone has a working example, would be nice to share it :wink:
Bye


#2

looks like the " are causing the problem, they are in the SNMP response but the check is probably stripping them thinking they surround the string you are trying to match, so it critical’s because response “All is OK.” does not match required string All is OK. exactly. You could try -s '"All is OK."'

HTH
/S


#3

It doesn’t work either.

I tried a few differents combinations :
’“All is OK.”’
“All is OK.”’ (like it’s displayed on the angios page)
’“All is OK\n”’ (like it’s in ethereal), with and without the acterisk
’“All is OK^J”’ (like it’s in tcpdump)

If someone has an other idea…

EDIT : btw : I’ve seen something : If I remove the “-s” form the check, it displays on the nagios page : SNMP CRITICAL - "All is OK"
while with the -s, it adds some asterisks : SNMP CRITICAL - “All is OK”


#4

[quote]EDIT : btw : I’ve seen something : If I remove the “-s” form the check, it displays on the nagios page : SNMP CRITICAL - "All is OK"
while with the -s, it adds some asterisks : SNMP CRITICAL - “All is OK”[/quote]

The text between the asterisks is the string returned from the device that check_snmp is comparing against what you havce written after the -s switch.

Strange that encapsulating in ’ does not work for you, it seemed to do the job here when I tried it. Can you use -r OK instead of -s ? Assuming of course when everything is not OK that the SNMP response won’t be “All is NOT OK.”…


#5

Well… solved…

Now, I juste hope, as you said, thait the error message does not contain the word “OK” :wink:

Thank you


#6

I know this is an old thread. You need to tell the command line that the quotes are not for itself with back slashes:

-s “All is OK”