From 6eca43522b65a3987c585231446dabb23f40ea22 Mon Sep 17 00:00:00 2001 From: Stefan Rinkes Date: Thu, 28 Apr 2011 19:43:09 +0200 Subject: [PATCH] pf plugin: also collect the current states sum --- src/pf.c | 19 ++++++++++++------- src/types.db | 1 + 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/pf.c b/src/pf.c index bbac3019..93fb5002 100644 --- 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; diff --git a/src/types.db b/src/types.db index b2845f66..744ea185 100644 --- a/src/types.db +++ b/src/types.db @@ -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 -- 2.11.0