summaryrefslogtreecommitdiffstats
path: root/plugins/check_snmp.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/check_snmp.c')
-rw-r--r--plugins/check_snmp.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c
index dcb3138..ce3919d 100644
--- a/plugins/check_snmp.c
+++ b/plugins/check_snmp.c
@@ -122,6 +122,7 @@ main (int argc, char **argv)
122 int result = STATE_UNKNOWN; 122 int result = STATE_UNKNOWN;
123 int return_code = 0; 123 int return_code = 0;
124 int external_error = 0; 124 int external_error = 0;
125 double perftmp;
125 char **command_line = NULL; 126 char **command_line = NULL;
126 char *cl_hidden_auth = NULL; 127 char *cl_hidden_auth = NULL;
127 char *oidname = NULL; 128 char *oidname = NULL;
@@ -351,10 +352,17 @@ main (int argc, char **argv)
351 if (nunits > (size_t)0 && (size_t)i < nunits && unitv[i] != NULL) 352 if (nunits > (size_t)0 && (size_t)i < nunits && unitv[i] != NULL)
352 asprintf (&outbuff, "%s %s", outbuff, unitv[i]); 353 asprintf (&outbuff, "%s %s", outbuff, unitv[i]);
353 354
354 if (is_numeric(show)) { 355 /* Try a two-way conversion of show and add perfdata only if we get
356 * something back at the end */
357 ptr = NULL;
358 perftmp = strtod(show, &ptr);
359 if (ptr != show) {
360 ptr = NULL;
361 asprintf(&ptr, "%0.9g", perftmp);
355 strncat(perfstr, oidname, sizeof(perfstr)-strlen(perfstr)-1); 362 strncat(perfstr, oidname, sizeof(perfstr)-strlen(perfstr)-1);
356 strncat(perfstr, "=", sizeof(perfstr)-strlen(perfstr)-1); 363 strncat(perfstr, "=", sizeof(perfstr)-strlen(perfstr)-1);
357 strncat(perfstr, show, sizeof(perfstr)-strlen(perfstr)-1); 364 strncat(perfstr, ptr, sizeof(perfstr)-strlen(perfstr)-1);
365 free(ptr);
358 366
359 if (type) 367 if (type)
360 strncat(perfstr, type, sizeof(perfstr)-strlen(perfstr)-1); 368 strncat(perfstr, type, sizeof(perfstr)-strlen(perfstr)-1);