pf plugin: also collect the current states sum
authorStefan Rinkes <stefan.rinkes@gmail.com>
Thu, 28 Apr 2011 17:43:09 +0000 (19:43 +0200)
committerFlorian Forster <octo@collectd.org>
Thu, 13 Sep 2012 11:10:04 +0000 (13:10 +0200)
src/pf.c
src/types.db

index bbac301..93fb500 100644 (file)
--- a/src/pf.c
+++ b/src/pf.c
@@ -19,7 +19,7 @@
 
 static int      pf_init(void);
 static int      pf_read(void);
-static void     submit_counter(const char *, const char *, counter_t);
+static void     submit_counter(const char *, const char *, counter_t, int);
 
 char           *pf_device = "/dev/pf";
 
@@ -72,25 +72,30 @@ pf_read(void)
        close(pfdev);
 
        for (i = 0; i < PFRES_MAX; i++)
-               submit_counter("pf_counters", cnames[i], status.counters[i]);
+               submit_counter("pf_counters", cnames[i], status.counters[i], 0);
        for (i = 0; i < LCNT_MAX; i++)
-               submit_counter("pf_limits", lnames[i], status.lcounters[i]);
+               submit_counter("pf_limits", lnames[i], status.lcounters[i], 0);
        for (i = 0; i < FCNT_MAX; i++)
-               submit_counter("pf_state", names[i], status.fcounters[i]);
+               submit_counter("pf_state", names[i], status.fcounters[i], 0);
        for (i = 0; i < SCNT_MAX; i++)
-               submit_counter("pf_source", names[i], status.scounters[i]);
+               submit_counter("pf_source", names[i], status.scounters[i], 0);
+
+       submit_counter("pf_states", "current", status.states, 1);
 
        return (0);
 }
 
 void
-submit_counter(const char *type, const char *inst, counter_t val)
+submit_counter(const char *type, const char *inst, counter_t val, int usegauge)
 {
 #ifndef TEST
        value_t         values[1];
        value_list_t    vl = VALUE_LIST_INIT;
 
-       values[0].counter = val;
+       if (usegauge)
+               values[0].gauge = val;
+       else
+               values[0].counter = val;
 
        vl.values = values;
        vl.values_len = 1;
index b2845f6..744ea18 100644 (file)
@@ -1,6 +1,7 @@
 pf_counters    value:COUNTER:0:U
 pf_limits      value:COUNTER:0:U
 pf_state       value:COUNTER:0:U
+pf_states      value:GAUGE:0:U
 pf_source      value:COUNTER:0:U
 states_cur     value:GAUGE:0:U
 states_tot     value:COUNTER:0:U