From: Florian Forster Date: Thu, 13 Sep 2012 12:01:40 +0000 (+0200) Subject: pf plugin: Remove the init() callback. X-Git-Tag: collectd-5.2.0~12^2~3 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=2f3702e5ad192b193c3e40a3fcc28eb418f7e76f;p=collectd.git pf plugin: Remove the init() callback. Instead check for a running PF in the read() callback. --- diff --git a/src/pf.c b/src/pf.c index 05b3cb58..4b5154d5 100644 --- a/src/pf.c +++ b/src/pf.c @@ -63,6 +63,9 @@ static int pf_read (void) close(pfdev); + if (!status.running) + return (-1); + for (i = 0; i < PFRES_MAX; i++) submit_counter("pf_counters", cnames[i], status.counters[i], 0); for (i = 0; i < LCNT_MAX; i++) @@ -77,31 +80,7 @@ static int pf_read (void) return (0); } -static int pf_init (void) -{ - struct pf_status status; - int pfdev = -1; - - if ((pfdev = open(pf_device, O_RDONLY)) == -1) { - ERROR("unable to open %s", pf_device); - return (-1); - } - - if (ioctl(pfdev, DIOCGETSTATUS, &status) == -1) { - ERROR("DIOCGETSTATUS: %i", pfdev); - close(pfdev); - return (-1); - } - - close(pfdev); - if (!status.running) - return (-1); - - return (0); -} - void module_register (void) { - plugin_register_init("pf", pf_init); plugin_register_read("pf", pf_read); }