summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d01c62d)
raw | patch | inline | side by side (parent: d01c62d)
author | Louis Opter <louis@dotcloud.com> | |
Tue, 28 Feb 2012 17:23:06 +0000 (18:23 +0100) | ||
committer | Florian Forster <octo@collectd.org> | |
Wed, 29 Feb 2012 09:34:21 +0000 (10:34 +0100) |
Dear collectd,
Please find attached a patch for the conntrack plugin.
The patch is about two things:
1. submit the value even if it is zero (which is a legitimate value according
to types.db);
2. use parse_value and a value_t instead of directly using a double and atof(3).
The first point was important because it meant that the metric was not created
when the initial value was zero. (It could also lead to holes in your graphs).
The parse_value return value is correctly checked, note that the parsed file
ends with a \n which mean that parse_value always complain when running in
debug/info maybe we should replace it with a \0 before handing the buffer to
parse_value() ?
Thanks
--
Louis Opter
Signed-off-by: Florian Forster <octo@collectd.org>
Please find attached a patch for the conntrack plugin.
The patch is about two things:
1. submit the value even if it is zero (which is a legitimate value according
to types.db);
2. use parse_value and a value_t instead of directly using a double and atof(3).
The first point was important because it meant that the metric was not created
when the initial value was zero. (It could also lead to holes in your graphs).
The parse_value return value is correctly checked, note that the parsed file
ends with a \n which mean that parse_value always complain when running in
debug/info maybe we should replace it with a \0 before handing the buffer to
parse_value() ?
Thanks
--
Louis Opter
Signed-off-by: Florian Forster <octo@collectd.org>
src/conntrack.c | patch | blob | history |
diff --git a/src/conntrack.c b/src/conntrack.c
index e70ff5f1834b5deecc53bfe7f0419176ce564eeb..4d6771244721c9d8e6c3049502de338e3b7e73e8 100644 (file)
--- a/src/conntrack.c
+++ b/src/conntrack.c
#define CONNTRACK_FILE "/proc/sys/net/netfilter/nf_conntrack_count"
-static void conntrack_submit (double conntrack)
+static void conntrack_submit (value_t conntrack)
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0].gauge = conntrack;
-
- vl.values = values;
+ vl.values = &conntrack;
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "conntrack", sizeof (vl.plugin));
static int conntrack_read (void)
{
- double conntrack;
+ value_t conntrack;
FILE *fh;
char buffer[64];
}
fclose (fh);
- conntrack = atof (buffer);
+ if (parse_value (buffer, &conntrack, DS_TYPE_GAUGE) == -1)
+ return (-1);
- if (conntrack > 0.0)
- conntrack_submit (conntrack);
+ conntrack_submit (conntrack);
return (0);
} /* static int conntrack_read */