#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 */