diff options
Diffstat (limited to 'plugins/check_snmp.c')
| -rw-r--r-- | plugins/check_snmp.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c index ce3919d1..fdb5819e 100644 --- a/plugins/check_snmp.c +++ b/plugins/check_snmp.c | |||
| @@ -117,12 +117,11 @@ int needmibs = FALSE; | |||
| 117 | int | 117 | int |
| 118 | main (int argc, char **argv) | 118 | main (int argc, char **argv) |
| 119 | { | 119 | { |
| 120 | int i; | 120 | int i, len; |
| 121 | int iresult = STATE_UNKNOWN; | 121 | int iresult = STATE_UNKNOWN; |
| 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; | ||
| 126 | char **command_line = NULL; | 125 | char **command_line = NULL; |
| 127 | char *cl_hidden_auth = NULL; | 126 | char *cl_hidden_auth = NULL; |
| 128 | char *oidname = NULL; | 127 | char *oidname = NULL; |
| @@ -352,17 +351,14 @@ main (int argc, char **argv) | |||
| 352 | if (nunits > (size_t)0 && (size_t)i < nunits && unitv[i] != NULL) | 351 | if (nunits > (size_t)0 && (size_t)i < nunits && unitv[i] != NULL) |
| 353 | asprintf (&outbuff, "%s %s", outbuff, unitv[i]); | 352 | asprintf (&outbuff, "%s %s", outbuff, unitv[i]); |
| 354 | 353 | ||
| 355 | /* Try a two-way conversion of show and add perfdata only if we get | 354 | /* Write perfdata with whatever can be parsed by strtod, if possible */ |
| 356 | * something back at the end */ | ||
| 357 | ptr = NULL; | 355 | ptr = NULL; |
| 358 | perftmp = strtod(show, &ptr); | 356 | strtod(show, &ptr); |
| 359 | if (ptr != show) { | 357 | if (ptr > show) { |
| 360 | ptr = NULL; | ||
| 361 | asprintf(&ptr, "%0.9g", perftmp); | ||
| 362 | strncat(perfstr, oidname, sizeof(perfstr)-strlen(perfstr)-1); | 358 | strncat(perfstr, oidname, sizeof(perfstr)-strlen(perfstr)-1); |
| 363 | strncat(perfstr, "=", sizeof(perfstr)-strlen(perfstr)-1); | 359 | strncat(perfstr, "=", sizeof(perfstr)-strlen(perfstr)-1); |
| 364 | strncat(perfstr, ptr, sizeof(perfstr)-strlen(perfstr)-1); | 360 | len = sizeof(perfstr)-strlen(perfstr)-1; |
| 365 | free(ptr); | 361 | strncat(perfstr, show, len>ptr-show ? ptr-show : len); |
| 366 | 362 | ||
| 367 | if (type) | 363 | if (type) |
| 368 | strncat(perfstr, type, sizeof(perfstr)-strlen(perfstr)-1); | 364 | strncat(perfstr, type, sizeof(perfstr)-strlen(perfstr)-1); |
