summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 08d8d11)
raw | patch | inline | side by side (parent: 08d8d11)
author | Thomas Guyot-Sionnest <dermoth@aei.ca> | |
Wed, 31 Mar 2010 02:31:20 +0000 (22:31 -0400) | ||
committer | Thomas Guyot-Sionnest <dermoth@aei.ca> | |
Wed, 31 Mar 2010 02:31:20 +0000 (22:31 -0400) |
Bug #1867716 fixed what it meant to fix: broken perfdata strings.
Unfortunately some users relied on half-broken perfdata string where at
least the first token was OK. This patch do a two-way conversion
(string to double then back to string) instead and use the conversion
result for the performance data.
A possible caveat is that the string may change where it normally
shouldn't but the result should be somewhat similar.
Unfortunately some users relied on half-broken perfdata string where at
least the first token was OK. This patch do a two-way conversion
(string to double then back to string) instead and use the conversion
result for the performance data.
A possible caveat is that the string may change where it normally
shouldn't but the result should be somewhat similar.
NEWS | patch | blob | history | |
plugins/check_snmp.c | patch | blob | history |
index 58768d396c423dc897ee01e84cbb497de994882b..e261abfdd245c73aec80afe919c927c99644d88e 100644 (file)
--- a/NEWS
+++ b/NEWS
Try to detect arguments passed via --with-ping[6]-command and set options accordingly (#2908236)
Fix memory leak in check_http for large pages (Jimmy Bergman - #2957455)
Fix compilation with GCC 2.96 (Konstantin Khomoutov - #2977105)
+ Fix regression introduced in #1867716 where partially valid performance strings would not be printed anymore
WARNINGS
Updated developer documentation to say that performance labels should not have an equals sign or
single quote in the label
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c
index dcb31386478e9b191ed8864c8681362fdde0a6ed..ce3919d1af4f3592f08b3fa229cffe1102ce4bc5 100644 (file)
--- a/plugins/check_snmp.c
+++ b/plugins/check_snmp.c
int result = STATE_UNKNOWN;
int return_code = 0;
int external_error = 0;
+ double perftmp;
char **command_line = NULL;
char *cl_hidden_auth = NULL;
char *oidname = NULL;
if (nunits > (size_t)0 && (size_t)i < nunits && unitv[i] != NULL)
asprintf (&outbuff, "%s %s", outbuff, unitv[i]);
- if (is_numeric(show)) {
+ /* Try a two-way conversion of show and add perfdata only if we get
+ * something back at the end */
+ ptr = NULL;
+ perftmp = strtod(show, &ptr);
+ if (ptr != show) {
+ ptr = NULL;
+ asprintf(&ptr, "%0.9g", perftmp);
strncat(perfstr, oidname, sizeof(perfstr)-strlen(perfstr)-1);
strncat(perfstr, "=", sizeof(perfstr)-strlen(perfstr)-1);
- strncat(perfstr, show, sizeof(perfstr)-strlen(perfstr)-1);
+ strncat(perfstr, ptr, sizeof(perfstr)-strlen(perfstr)-1);
+ free(ptr);
if (type)
strncat(perfstr, type, sizeof(perfstr)-strlen(perfstr)-1);