aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Stephane Lapie <stephane.lapie@asahinet.com> 2013-11-15 11:04:55 +0900
committerGravatar Thomas Guyot-Sionnest <dermoth@aei.ca> 2014-01-31 00:49:18 -0500
commit35811848da1095525e6937159f6611fc8a87261b (patch)
treee7eaa71beb82c1bb9a181f35a2ec013c4f928179
parentc4e3cd6efd5aef8665db103a66996e619526ab3b (diff)
downloadmonitoring-plugins-35811848da1095525e6937159f6611fc8a87261b.tar.gz
Handle negative values properly with check_snmp
check_snmp becomes capable of evaluating negative values properly, but it might be returning CRITICALs where it used to return OK and was ignored, if a negative value turns out to actually be a valid value. If negative values are valid, this can be worked around, by adding "~:" to the warning/critical threshold : 100 -> ~:100
-rw-r--r--lib/utils_base.h2
-rw-r--r--plugins/check_snmp.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/lib/utils_base.h b/lib/utils_base.h
index 04f6370c..d69b0da1 100644
--- 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 *);
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c
index ca17970c..d516fbc1 100644
--- a/plugins/check_snmp.c
+++ b/plugins/check_snmp.c
@@ -459,7 +459,7 @@ main (int argc, char **argv)
/* Process this block for numeric comparisons */
/* Make some special values,like Timeticks numeric only if a threshold is defined */
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 (%s)\n"), show);
while (i >= response_size) {