summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c29fa0a)
raw | patch | inline | side by side (parent: c29fa0a)
author | Florian Forster <octo@collectd.org> | |
Thu, 13 Sep 2012 12:01:40 +0000 (14:01 +0200) | ||
committer | Florian Forster <octo@collectd.org> | |
Thu, 13 Sep 2012 12:01:40 +0000 (14:01 +0200) |
Instead check for a running PF in the read() callback.
src/pf.c | patch | blob | history |
diff --git a/src/pf.c b/src/pf.c
index 05b3cb588616db468f63fb90cbbe6a135200634c..4b5154d5d8166ff6703f78f435d44e0c774c4299 100644 (file)
--- a/src/pf.c
+++ b/src/pf.c
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++)
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);
}