SOLVED!: Using check_snmp to alert on text strings

Hi all –

I have an SNMP capable device that returns either “Alarm” or “Clear” as a string for a particular OID I want to watch.

When I do this:
snmpget -c -v 2c 1.3.6.1.4.1.2682.1.2.5.1.6.99.1.1.1

I get this:
SNMPv2-SMI::enterprises.2682.1.2.5.1.6.99.1.1.1 = STRING: “Clear”

I’ve read the docs for check_snmp, and I understand a bit about the “-s” option telling check_snmp to look for a string.

What I’m not clear about is how (or if) I need to use the “-w” and “-c” switches??

This is what I’ve got so far – and it’s working, but always says “CRITICAL” no matter what the actual string that’s returned is.
check_command check_snmp!-C -l GeneratorPower -o 1.3.6.1.4.1.2682.1.2.5.1.6.99.1.1.1 -s=Clear

This is what I’m getting back every time:
"GeneratorPower CRITICAL 02-17-2011 15:56:39 0d 0h 0m 26s 1/4 GeneratorPower CRITICAL - “Clear” "

What am I missing about how to get that SNMP string “Clear” to be recognized as an “everything’s OK” message, and
a state of “Alarm” as a notification??

btw-

I just found this in another thread

"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”

I tried that – Nagios promptly started telling me that I was missing the final “}” at the end of the stanza.
Remove the “”, and the error goes away.

I get the need to escape the quotes, so that Nagios knows that they are part of the string to be compared.
But how do you do that without Nagios seeing that “” as the end of the stanza, and thinking you don’t have that final “}” in your config?

I tried this at the command line
/usr/local/nagios/libexec/check_snmp -H -C -l UtilityPower -s=“Clear”\ -o 1.3.6.1.4.1.2682.1.2.5.1.6.99.1.1.1

That got me handed the “>” prompt on the next line, indicating that Bash thought I wasn’t finished with the line - like you get in Perl or MySQL when you forget the closing “;”

I have also been trying the -R and -r options for regular expression.

No go –

For the benefit of others who may Google for this in the future -

I got the “-R” option to work as follows:

/usr/local/nagios/libexec/check_snmp -H -C -l UtilityPower -R=*lear -o

You get back this
UtilityPower OK - “Clear” |

/usr/local/nagios/libexec/check_snmp -H -C -l UtilityPower -R=*larm -o

UtilityPower CRITICAL - “Clear” |

(The last test does still show clear because there’s not actually an alarm at the moment - notice that I changed the string to something different, causing a mismatch on the server side, not the instrumentation side.

thanks for the complete solution and update :slight_smile: