[Nagiosplug-devel] [ nagiosplug-Bugs-3552834 ] check_snmp threshold breaks with negative values
SourceForge.net
noreply at sourceforge.net
Wed Aug 1 01:00:11 CEST 2012
Bugs item #3552834, was opened at 2012-07-31 16:00
Message generated for change (Tracker Item Submitted) made by calestyo
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=397597&aid=3552834&group_id=29880
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Cálestyo (calestyo)
Assigned to: Nobody/Anonymous (nobody)
Summary: check_snmp threshold breaks with negative values
Initial Comment:
Hi.
This is from the old / soon to be disabled again Nagios Plugins bug tracker that used to be at Nagios itself.
I've just copied this bug over. I'm not the original reporter and have no idea about the thoughts about this bug.
This used to be: http://tracker.nagios.org/view.php?id=265
--------------------------------------------------------------------------------
candlerb:
--------------------------------------------------------------------------------
The INTEGER type in SNMP is a signed 32-bit value. However check_snmp breaks with negative values.
(1) The negative sign is dropped as soon as you apply -w or -c command line flags.
# /usr/lib/nagios/plugins/check_snmp -vvv -H 192.168.5.119 -C public -o .1.3.6.1.2.1.25.2.3.1.5.2
/usr/bin/snmpget -t 1 -r 5 -m '' -v 1 [authpriv] 192.168.5.119:161 .1.3.6.1.2.1.25.2.3.1.5.2
iso.3.6.1.2.1.25.2.3.1.5.2 = INTEGER: -632823937
Processing line 1
oidname: iso.3.6.1.2.1.25.2.3.1.5.2
response: = INTEGER: -632823937
SNMP OK - -632823937 | iso.3.6.1.2.1.25.2.3.1.5.2=-632823937
# /usr/lib/nagios/plugins/check_snmp -vvv -H 192.168.5.119 -C public -o .1.3.6.1.2.1.25.2.3.1.5.2 -w 0
/usr/bin/snmpget -t 1 -r 5 -m '' -v 1 [authpriv] 192.168.5.119:161 .1.3.6.1.2.1.25.2.3.1.5.2
iso.3.6.1.2.1.25.2.3.1.5.2 = INTEGER: -632823937
Processing line 1
oidname: iso.3.6.1.2.1.25.2.3.1.5.2
response: = INTEGER: -632823937
SNMP WARNING - *632823937* | iso.3.6.1.2.1.25.2.3.1.5.2=632823937 <<< NOTE!
(2) Any threshold with a negative value is rejected as invalid
# /usr/lib/nagios/plugins/check_snmp -vvv -H 192.168.5.119 -C public -o .1.3.6.1.2.1.25.2.3.1.5.2 -w -5:-3
Range format incorrect
I am guessing problem (1) could be fixed like this:
--- a/plugins/check_snmp.c
+++ b/plugins/check_snmp.c
@@ -401,7 +401,7 @@ main (int argc, char **argv)
/* Process this block for numeric comparisons */
/* Make some special values,like Timeticks numeric only if a thr
if (thlds[i]->warning || thlds[i]->critical || calculate_rate) {
- ptr = strpbrk (show, "0123456789");
+ ptr = strpbrk (show, "-0123456789");
if (ptr == NULL)
die (STATE_UNKNOWN,_("No valid data returned"));
response_value[i] = strtod (ptr, NULL);
and that problem (2) could be fixed like this:
--- a/lib/utils_base.h
+++ b/lib/utils_base.h
@@ -62,7 +62,7 @@ int check_range(double, range *);
int get_status(double, thresholds *);
/* All possible characters in a threshold range */
-#define NP_THRESHOLDS_CHARS "0123456789.:@~"
+#define NP_THRESHOLDS_CHARS "-0123456789.:@~"
char *np_escaped_string (const char *);
--------------------------------------------------------------------------------
candlerb:
--------------------------------------------------------------------------------
I have rebuild check_snmp from source, and those two one-line changes do appear to fix the problem.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=397597&aid=3552834&group_id=29880
More information about the Devel
mailing list