Code

Merge remote-tracking branch 'github/pr/387'
[collectd.git] / src / pf.c
index 8dc6d83b638783d799afdcdd3f163d1a152a8d80..44f0c7bcdec158b3244ec6f7b0d9212b9cd652d5 100644 (file)
--- a/src/pf.c
+++ b/src/pf.c
 
 #include "collectd.h"
 #include "plugin.h"
+#include "common.h"
+
+#if HAVE_SYS_IOCTL_H
+# include <sys/ioctl.h>
+#endif
+#if HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
+#if HAVE_NET_IF_H
+# include <net/if.h>
+#endif
 
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <net/if.h>
 #include <net/pfvar.h>
-#include <paths.h>
-#include <err.h>
-#include <pwd.h>
+
+#ifndef FCNT_NAMES
+# if FCNT_MAX != 3
+#  error "Unexpected value for FCNT_MAX"
+# endif
+# define FCNT_NAMES {"search", "insert", "removals", NULL};
+#endif
+
+#ifndef SCNT_NAMES
+# if SCNT_MAX != 3
+#  error "Unexpected value for SCNT_MAX"
+# endif
+# define SCNT_NAMES {"search", "insert", "removals", NULL};
+#endif
 
 static char const *pf_reasons[PFRES_MAX+1] = PFRES_NAMES;
 static char const *pf_lcounters[LCNT_MAX+1] = LCNT_NAMES;
 static char const *pf_fcounters[FCNT_MAX+1] = FCNT_NAMES;
-static char const *pf_scounters[FCNT_MAX+1] = FCNT_NAMES;
+static char const *pf_scounters[SCNT_MAX+1] = SCNT_NAMES;
 
 static char const *pf_device = "/dev/pf";
 
@@ -85,7 +104,7 @@ static int pf_read (void)
        close (fd);
        fd = -1;
 
-       if (!status.running)
+       if (!state.running)
        {
                WARNING ("pf plugin: PF is not running.");
                return (-1);