summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d437681)
raw | patch | inline | side by side (parent: d437681)
author | Pierre-Yves Ritschard <pyr@spootnik.org> | |
Tue, 29 Jul 2014 09:10:45 +0000 (11:10 +0200) | ||
committer | Pierre-Yves Ritschard <pyr@spootnik.org> | |
Tue, 29 Jul 2014 09:10:45 +0000 (11:10 +0200) |
supersedes collectd/collectd#605
src/collectd.conf.pod | patch | blob | history | |
src/conntrack.c | patch | blob | history |
diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod
index 32ed99034cf0d4cc907fd5499e18a774737a3430..8b9157d9b0536835bd28ae2c23614e76f358a43b 100644 (file)
--- a/src/collectd.conf.pod
+++ b/src/collectd.conf.pod
=back
+=head2 Plugin C<conntrack>
+
+This plugin collects IP conntrack statistics.
+
+=over 4
+
+=item B<OldFiles>
+
+Assume the B<conntrack_count> and B<conntrack_max> files to be found in
+F</proc/sys/net/ipv4/netfilter> instead of F</proc/sys/net/netfilter/>.
+
+=back
+
=head2 Plugin C<cpu>
The I<CPU plugin> collects CPU usage metrics.
diff --git a/src/conntrack.c b/src/conntrack.c
index e7bccad353064f6e8d16a6b6420a303b51a017a0..b8f8dfd8ae8d88c0faa6a978acee5a9d01903f34 100644 (file)
--- a/src/conntrack.c
+++ b/src/conntrack.c
#define CONNTRACK_FILE "/proc/sys/net/netfilter/nf_conntrack_count"
#define CONNTRACK_MAX_FILE "/proc/sys/net/netfilter/nf_conntrack_max"
+#define CONNTRACK_FILE_OLD "/proc/sys/net/ipv4/netfilter/ip_conntrack_count"
+#define CONNTRACK_MAX_FILE_OLD "/proc/sys/net/ipv4/netfilter/ip_conntrack_max"
+
+static const char *config_keys[] =
+{
+ "OldFiles"
+};
+static int config_keys_num = STATIC_ARRAY_SIZE (config_keys);
+/*
+ Each table/chain combo that will be queried goes into this list
+*/
+
+static int old_files = 0;
+
+static int conntrack_config(const char *key, const char *value)
+{
+ if (strcmp(key, "OldFiles") == 0)
+ old_files = 1;
+
+ return 0;
+}
static void conntrack_submit (const char *type, const char *type_instance,
value_t conntrack)
char buffer[64];
size_t buffer_len;
- fh = fopen (CONNTRACK_FILE, "r");
+ fh = fopen (old_files?CONNTRACK_FILE_OLD:CONNTRACK_FILE, "r");
if (fh == NULL)
return (-1);
conntrack_submit ("conntrack", NULL, conntrack);
- fh = fopen (CONNTRACK_MAX_FILE, "r");
+ fh = fopen (old_files?CONNTRACK_MAX_FILE_OLD:CONNTRACK_MAX_FILE, "r");
if (fh == NULL)
return (-1);
void module_register (void)
{
+ plugin_register_config ("conntrack", conntrack_config,
+ config_keys, config_keys_num);
plugin_register_read ("conntrack", conntrack_read);
} /* void module_register */