Page 1 of 1

check_snmp - STRING value and Ranges

Posted: Tue Jul 09, 2013 1:31 am
by mrninni
Hi all,

One of my devices returns a value in STRING format:

Code: Select all

[]# snmpget -v2c -cpublic 192.168.1.1 .1.3.6.1.4.1.3640.1.1.1.20.2.1.1.1362211967.1206910998.28
SNMPv2-SMI::enterprises.3640.1.1.1.20.2.1.1.1362211967.1206910998.28 = STRING: "-65.81"

[]#./check_snmp -C public -H 192.168.1.1 -o .1.3.6.1.4.1.3640.1.1.1.20.2.1.1.1309280830.2749366273.28
SNMP OK - "-65.81" |
I'd like to insert a threshold in order to launch an alarm (i.e. if the value drops under -70).
I usually use the check_snmp options -w and -c, but maybe them work only with INTEGER values.

There is a simple solution mixing the check_snmp options?

Many thanks

Re: check_snmp - STRING value and Ranges

Posted: Tue Jul 09, 2013 1:04 pm
by abrist
As it returns a string, you will have to create your own plugin script to convert the string to a number (maybe round it to an integer as well) and then check your thresholds that way.

Re: check_snmp - STRING value and Ranges

Posted: Wed Jul 10, 2013 12:31 am
by mrninni
Ok thanks, understood.

Re: check_snmp - STRING value and Ranges

Posted: Wed Jul 10, 2013 11:10 am
by abrist
Just to pile on here, in bash, variables are technically untyped, though many of the nagios plugins, written in C, are typed. You could write your own script to snmpget the oid and then run a comparison. If you wish to round in bash, sed is usually my preferred way of doing it:

Code: Select all

echo "86.909" | sed 's/\..*//'