summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: cfb86a0)
raw | patch | inline | side by side (parent: cfb86a0)
author | Tomasz Pala <gotar@pld-linux.org> | |
Tue, 31 Mar 2009 08:31:29 +0000 (10:31 +0200) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Fri, 17 Apr 2009 23:13:30 +0000 (01:13 +0200) |
Hello,
I've adapted entropy plugin to get nf_conntrack entries, which is
important on Linux routers. Attached patch.
BTW you may want to take a look at PLD Linux spec file at
http://cvs.pld-linux.org/cgi-bin/cvsweb/SPECS/collectd.spec or
http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/SPECS/collectd.spec
as it's much more complex than Fedora, RH or SLES ones which are shipped
in contrib.
--
Tomasz Pala <gotar@pld-linux.org>
I've adapted entropy plugin to get nf_conntrack entries, which is
important on Linux routers. Attached patch.
BTW you may want to take a look at PLD Linux spec file at
http://cvs.pld-linux.org/cgi-bin/cvsweb/SPECS/collectd.spec or
http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/SPECS/collectd.spec
as it's much more complex than Fedora, RH or SLES ones which are shipped
in contrib.
--
Tomasz Pala <gotar@pld-linux.org>
13 files changed:
AUTHORS | patch | blob | history | |
README | patch | blob | history | |
configure.in | patch | blob | history | |
contrib/collection.cgi | patch | blob | history | |
contrib/collection3/etc/collection.conf | patch | blob | history | |
contrib/fedora/collectd.spec | patch | blob | history | |
contrib/php-collection/definitions.php | patch | blob | history | |
contrib/redhat/collectd.conf | patch | blob | history | |
contrib/redhat/collectd.spec | patch | blob | history | |
src/Makefile.am | patch | blob | history | |
src/collectd.conf.in | patch | blob | history | |
src/conntrack.c | [new file with mode: 0644] | patch | blob |
src/types.db | patch | blob | history |
index ff879c4d940d3192bef5ae10c517a947f4168cfa..2c8c94bb676f4d8ea33b67b7cf904639c6ed7fa1 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
Stefan Hacker <stefan.hacker at web.de>
- teamspeak2 plugin.
+Tomasz Pala <gotar at pld-linux.org>
+ - conntrack plugin.
+
Tommie Gannert <d00-tga at d.kth.se>
- PID-file patch.
index c556c750ce9eeca1d457f8b8d9dc648ff6bc9901..755704d91b63933e22443329e7f2b515b338aa43 100644 (file)
--- a/README
+++ b/README
Name server and resolver statistics from the `statistics-channel'
interface of BIND 9.5, 9,6 and later.
+ - conntrack
+ Number of nf_conntrack entries.
+
- cpu
CPU utilization: Time spent in the system, user, nice, idle, and related
states.
diff --git a/configure.in b/configure.in
index f0c43121990012b19cae6be48cd5bac488b2b650..591de4ff7beb93fb70eae4cb2c5b149a33ea2eb4 100644 (file)
--- a/configure.in
+++ b/configure.in
plugin_ascent="no"
plugin_battery="no"
plugin_bind="no"
+plugin_conntrack="no"
plugin_cpu="no"
plugin_cpufreq="no"
plugin_df="no"
if test "x$ac_system" = "xLinux"
then
plugin_battery="yes"
+ plugin_conntrack="yes"
plugin_cpu="yes"
plugin_cpufreq="yes"
plugin_disk="yes"
AC_PLUGIN([ascent], [$plugin_ascent], [AscentEmu player statistics])
AC_PLUGIN([battery], [$plugin_battery], [Battery statistics])
AC_PLUGIN([bind], [$plugin_bind], [ISC Bind nameserver statistics])
+AC_PLUGIN([conntrack], [$plugin_conntrack], [nf_conntrack statistics])
AC_PLUGIN([cpufreq], [$plugin_cpufreq], [CPU frequency statistics])
AC_PLUGIN([cpu], [$plugin_cpu], [CPU usage statistics])
AC_PLUGIN([csv], [yes], [CSV output plugin])
ascent . . . . . . . $enable_ascent
battery . . . . . . . $enable_battery
bind . . . . . . . . $enable_bind
+ conntrack . . . . . . $enable_conntrack
cpu . . . . . . . . . $enable_cpu
cpufreq . . . . . . . $enable_cpufreq
csv . . . . . . . . . $enable_csv
diff --git a/contrib/collection.cgi b/contrib/collection.cgi
index d3a284f88457245fc2171b82e6b7943212ecfa5c..eeda241df00c18682ccd27a41268c2178a003485 100755 (executable)
--- a/contrib/collection.cgi
+++ b/contrib/collection.cgi
'GPRINT:max:MAX:%4.1lf Max,',
'GPRINT:avg:LAST:%4.1lf Last\l'
],
+ conntrack => ['-v', 'Entries',
+ 'DEF:avg={file}:entropy:AVERAGE',
+ 'DEF:min={file}:entropy:MIN',
+ 'DEF:max={file}:entropy:MAX',
+ "AREA:max#$HalfBlue",
+ "AREA:min#$Canvas",
+ "LINE1:avg#$FullBlue:Count",
+ 'GPRINT:min:MIN:%4.0lf Min,',
+ 'GPRINT:avg:AVERAGE:%4.0lf Avg,',
+ 'GPRINT:max:MAX:%4.0lf Max,',
+ 'GPRINT:avg:LAST:%4.0lf Last\l'
+ ],
entropy => ['-v', 'Bits',
'DEF:avg={file}:entropy:AVERAGE',
'DEF:min={file}:entropy:MIN',
index 2511221f96f61c288ce6c6a0f84d9f362a6812d9..492bfa27730bd4a002d31b8324f4d535db49827a 100644 (file)
RRDVerticalLabel "Queries/s"
RRDFormat "%6.1lf"
</Type>
+<Type conntrack>
+ DataSources conntrack
+ DSName conntrack Conntrack count
+ RRDTitle "nf_conntrack connections on {hostname}"
+ RRDVerticalLabel "Count"
+ RRDFormat "%4.0lf"
+</Type>
<Type entropy>
DataSources entropy
DSName entropy Entropy bits
index 35eb8bec1eb61e1d74bd63f9cfa326cd0d3e15b6..a35923c0bd646e37164ded1552cae28104e2f764 100644 (file)
%attr(0644,root,root) %{_libdir}/%{name}/battery.so*
%attr(0644,root,root) %{_libdir}/%{name}/battery.la
+%attr(0644,root,root) %{_libdir}/%{name}/conntrack.so*
+%attr(0644,root,root) %{_libdir}/%{name}/conntrack.la
+
%attr(0644,root,root) %{_libdir}/%{name}/cpufreq.so*
%attr(0644,root,root) %{_libdir}/%{name}/cpufreq.la
index cb3e803e27f285649560d1ad47e8a946a3c33c7a..a0f381805b9acc012d5cf9e1cc172b0ab29f1c42 100644 (file)
'GPRINT:avg:AVERAGE:%4.1lf Avg,',
'GPRINT:max:MAX:%4.1lf Max,',
'GPRINT:avg:LAST:%4.1lf Last\l');
+ $GraphDefs['conntrack'] = array(
+ '-v', 'Entries',
+ 'DEF:avg={file}:entropy:AVERAGE',
+ 'DEF:min={file}:entropy:MIN',
+ 'DEF:max={file}:entropy:MAX',
+ "AREA:max#$HalfBlue",
+ "AREA:min#$Canvas",
+ "LINE1:avg#$FullBlue:Count",
+ 'GPRINT:min:MIN:%4.0lf Min,',
+ 'GPRINT:avg:AVERAGE:%4.0lf Avg,',
+ 'GPRINT:max:MAX:%4.0lf Max,',
+ 'GPRINT:avg:LAST:%4.0lf Last\l');
$GraphDefs['entropy'] = array(
'-v', 'Bits',
'DEF:avg={file}:entropy:AVERAGE',
index 0aaaee317bcfb71c7689e4181fe1e873fe33cc2c..f8352ffac4782ff37da8ffeeb16138d921ff1834 100644 (file)
LoadPlugin apcups
#LoadPlugin apple_sensors
LoadPlugin battery
+LoadPlugin conntrack
LoadPlugin cpu
LoadPlugin cpufreq
LoadPlugin csv
index 62acc184acf7c31c4cf368d00187b55c62afd69c..012fc48048c4d7faf9ce3e1aa6dbea363e1da868 100644 (file)
%attr(0644,root,root) %{_libdir}/%{name}/battery.so*
%attr(0644,root,root) %{_libdir}/%{name}/battery.la
+%attr(0644,root,root) %{_libdir}/%{name}/conntrack.so*
+%attr(0644,root,root) %{_libdir}/%{name}/conntrack.la
+
%attr(0644,root,root) %{_libdir}/%{name}/cpufreq.so*
%attr(0644,root,root) %{_libdir}/%{name}/cpufreq.la
diff --git a/src/Makefile.am b/src/Makefile.am
index 9b85144fadd0ac9b62c0bf5b8464125a0e0142f0..8f94b01a503290f2dbbe258c41233f381c124849 100644 (file)
--- a/src/Makefile.am
+++ b/src/Makefile.am
collectd_DEPENDENCIES += bind.la
endif
+if BUILD_PLUGIN_CONNTRACK
+pkglib_LTLIBRARIES += conntrack.la
+conntrack_la_SOURCES = conntrack.c
+conntrack_la_LDFLAGS = -module -avoid-version
+collectd_LDADD += "-dlopen" conntrack.la
+collectd_DEPENDENCIES += conntrack.la
+endif
+
if BUILD_PLUGIN_CPU
pkglib_LTLIBRARIES += cpu.la
cpu_la_SOURCES = cpu.c
diff --git a/src/collectd.conf.in b/src/collectd.conf.in
index 6783a15c38c190de6fc6a35049d6e74b34e9ab55..92df4a7b65f75f3a97e772a2b48ce4f4e912c9ae 100644 (file)
--- a/src/collectd.conf.in
+++ b/src/collectd.conf.in
#@BUILD_PLUGIN_ASCENT_TRUE@LoadPlugin ascent
#@BUILD_PLUGIN_BATTERY_TRUE@LoadPlugin battery
#@BUILD_PLUGIN_BIND_TRUE@LoadPlugin bind
+#@BUILD_PLUGIN_CONNTRACK_TRUE@LoadPlugin conntrack
@BUILD_PLUGIN_CPU_TRUE@@BUILD_PLUGIN_CPU_TRUE@LoadPlugin cpu
#@BUILD_PLUGIN_CPUFREQ_TRUE@LoadPlugin cpufreq
@LOAD_PLUGIN_CSV@LoadPlugin csv
diff --git a/src/conntrack.c b/src/conntrack.c
--- /dev/null
+++ b/src/conntrack.c
@@ -0,0 +1,78 @@
+/**
+ * collectd - src/conntrack.c
+ * Copyright (C) 2009 Tomasz Pala
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; only version 2 of the License is applicable.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Authors:
+ * Tomasz Pala <gotar at pld-linux.org>
+ * based on entropy.c by:
+ * Florian octo Forster <octo at verplant.org>
+ **/
+
+#include "collectd.h"
+#include "common.h"
+#include "plugin.h"
+
+#if !KERNEL_LINUX
+# error "No applicable input method."
+#endif
+
+#define CONNTRACK_FILE "/proc/sys/net/netfilter/nf_conntrack_count"
+
+static void conntrack_submit (double conntrack)
+{
+ value_t values[1];
+ value_list_t vl = VALUE_LIST_INIT;
+
+ values[0].gauge = conntrack;
+
+ vl.values = values;
+ vl.values_len = 1;
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "conntrack", sizeof (vl.plugin));
+ sstrncpy (vl.type, "conntrack", sizeof (vl.type));
+
+ plugin_dispatch_values (&vl);
+} /* static void conntrack_submit */
+
+static int conntrack_read (void)
+{
+ double conntrack;
+ FILE *fh;
+ char buffer[64];
+
+ fh = fopen (CONNTRACK_FILE, "r");
+ if (fh == NULL)
+ return (-1);
+
+ if (fgets (buffer, sizeof (buffer), fh) == NULL)
+ {
+ fclose (fh);
+ return (-1);
+ }
+ fclose (fh);
+
+ conntrack = atof (buffer);
+
+ if (conntrack > 0.0)
+ conntrack_submit (conntrack);
+
+ return (0);
+} /* static int conntrack_read */
+
+void module_register (void)
+{
+ plugin_register_read ("conntrack", conntrack_read);
+} /* void module_register */
diff --git a/src/types.db b/src/types.db
index b38c207a66b95a596e7086af6a24f2436609ffca..e07329c2df9b1a6191f341436991b99766773ba2 100644 (file)
--- a/src/types.db
+++ b/src/types.db
charge value:GAUGE:0:U
compression_ratio value:GAUGE:0:2
connections value:COUNTER:0:U
+conntrack entropy:GAUGE:0:4294967295
counter value:COUNTER:U:U
cpufreq value:GAUGE:0:U
cpu value:COUNTER:0:4294967295