check_snmp - STRING value and Ranges

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
mrninni
Posts: 27
Joined: Tue Sep 27, 2011 8:35 am

check_snmp - STRING value and Ranges

Post 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
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: check_snmp - STRING value and Ranges

Post 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.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
mrninni
Posts: 27
Joined: Tue Sep 27, 2011 8:35 am

Re: check_snmp - STRING value and Ranges

Post by mrninni »

Ok thanks, understood.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: check_snmp - STRING value and Ranges

Post 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/\..*//'
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Locked