summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3d6e459)
raw | patch | inline | side by side (parent: 3d6e459)
author | Sebastian Harl <sh@tokkee.org> | |
Wed, 21 May 2008 14:50:07 +0000 (16:50 +0200) | ||
committer | Florian Forster <octo@huhu.verplant.org> | |
Tue, 27 May 2008 11:10:31 +0000 (13:10 +0200) |
When disambiguating the protocol used by the unixsock plugin in commit
90287c6d240a168fca8d01f8330e2e2263e1f0a4 ("Disambiguated the protocol used
by the unixsock (and other) plugins.") the formatting of the return values
of the "GETVAL" command has been modified. This patch updates
collectd-nagios to handle the new format correctly.
Signed-off-by: Sebastian Harl <sh@tokkee.org>
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
90287c6d240a168fca8d01f8330e2e2263e1f0a4 ("Disambiguated the protocol used
by the unixsock (and other) plugins.") the formatting of the return values
of the "GETVAL" command has been modified. This patch updates
collectd-nagios to handle the new format correctly.
Signed-off-by: Sebastian Harl <sh@tokkee.org>
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
src/collectd-nagios.c | patch | blob | history |
diff --git a/src/collectd-nagios.c b/src/collectd-nagios.c
index f4dff5bb99a5efeb64d2a48f314c18e458848e03..1bf5b3f3dc6061be372aa725d5766dbc7283fe64 100644 (file)
--- a/src/collectd-nagios.c
+++ b/src/collectd-nagios.c
fclose (fh_out);
return (-1);
}
- fclose (fh_in); fh_in = NULL; fd = -1;
- fclose (fh_out); fh_out = NULL;
- values_num = atoi (buffer);
- if (values_num < 1)
- return (-1);
+ {
+ char *ptr = strchr (buffer, ' ');
+
+ if (ptr != NULL)
+ *ptr = '\0';
+
+ values_num = atoi (buffer);
+ if (values_num < 1)
+ return (-1);
+ }
values = (double *) malloc (values_num * sizeof (double));
if (values == NULL)
return (-1);
}
+ i = 0;
+ while (fgets (buffer, sizeof (buffer), fh_in) != NULL)
{
- char *ptr = strchr (buffer, ' ') + 1;
char *key;
char *value;
- i = 0;
- while ((key = strtok (ptr, " \t")) != NULL)
- {
- ptr = NULL;
- value = strchr (key, '=');
- if (value == NULL)
- continue;
- *value = '\0'; value++;
+ key = buffer;
- if (ignore_ds (key) != 0)
- continue;
+ value = strchr (key, '=');
+ if (value == NULL)
+ continue;
+ *value = '\0'; value++;
- values_names[i] = strdup (key);
- values[i] = atof (value);
+ if (ignore_ds (key) != 0)
+ continue;
- i++;
- if (i >= values_num)
- break;
- }
- values_num = i;
+ values_names[i] = strdup (key);
+ values[i] = atof (value);
+
+ i++;
+ if (i >= values_num)
+ break;
}
+ values_num = i;
+
+ fclose (fh_in); fh_in = NULL; fd = -1;
+ fclose (fh_out); fh_out = NULL;
*ret_values_num = values_num;
*ret_values = values;