From: Stefan Rinkes Date: Sat, 16 Apr 2011 09:06:56 +0000 (+0200) Subject: pf plugin: add very simple rule monitoring X-Git-Tag: collectd-5.2.0~12^2~24 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=9c9c2655d85e0935da253617dccf5279a9868b88;p=collectd.git pf plugin: add very simple rule monitoring --- diff --git a/src/pf.c b/src/pf.c index b4d2a458..02eb5aed 100644 --- a/src/pf.c +++ b/src/pf.c @@ -15,39 +15,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef TEST -#include "collectd.h" -#include "common.h" -#include "plugin.h" -#include "configfile.h" -#else -#include -typedef u_int64_t counter_t; -#endif - -#define PF_SOCKET "/dev/pf" - -struct pfdata { - int pd_dev; -}; - -static struct pfdata pd; +#include "pfcommon.h" static int pf_init(void); static int pf_read(void); @@ -80,16 +48,14 @@ pf_init(void) { struct pf_status status; - memset(&pd, '\0', sizeof(pd)); - - if ((pd.pd_dev = open(PF_SOCKET, O_RDWR)) == -1) { + if ((dev = open(PF_SOCKET, O_RDWR)) == -1) { return (-1); } - if (ioctl(pd.pd_dev, DIOCGETSTATUS, &status) == -1) { + if (ioctl(dev, DIOCGETSTATUS, &status) == -1) { return (-1); } - close(pd.pd_dev); + close(dev); if (!status.running) return (-1); @@ -106,14 +72,14 @@ pf_read(void) char *lnames[] = LCNT_NAMES; char *names[] = { "searches", "inserts", "removals" }; - if ((pd.pd_dev = open(PF_SOCKET, O_RDWR)) == -1) { + if ((dev = open(PF_SOCKET, O_RDWR)) == -1) { return (-1); } - if (ioctl(pd.pd_dev, DIOCGETSTATUS, &status) == -1) { + if (ioctl(dev, DIOCGETSTATUS, &status) == -1) { return (-1); } - close(pd.pd_dev); + close(dev); for (i = 0; i < PFRES_MAX; i++) submit_counter("pf_counters", cnames[i], status.counters[i]); for (i = 0; i < LCNT_MAX; i++) diff --git a/types.pfrules.db b/types.pfrules.db new file mode 100644 index 00000000..5bf5c864 --- /dev/null +++ b/types.pfrules.db @@ -0,0 +1,8 @@ +scrub_states_current value:GAUGE:U:U +scrub_states_total value:GAUGE:U:U +scrub_evaluations value:GAUGE:U:U +scrub_bytes value:GAUGE:U:U +rule_states_current value:GAUGE:U:U +rule_states_total value:GAUGE:U:U +rule_evaluations value:GAUGE:U:U +rule_bytes value:GAUGE:U:U