From: Tom Hughes Date: Tue, 24 Sep 2013 23:21:19 +0000 (+0100) Subject: Add newer version of fw_conntrack munin plugin X-Git-Url: https://git.openstreetmap.org/chef.git/commitdiff_plain/e61233b42038a7b4cbb793b19c49a0109c7c9c09 Add newer version of fw_conntrack munin plugin The version shipped with Ubuntu 12.04 doesn't work with newer kernels where the conntrack tool must be used to access the connection tracking data. --- diff --git a/cookbooks/munin/files/default/plugins/fw_conntrack b/cookbooks/munin/files/default/plugins/fw_conntrack index 1a1b59f0c..c575dd8cc 100755 --- a/cookbooks/munin/files/default/plugins/fw_conntrack +++ b/cookbooks/munin/files/default/plugins/fw_conntrack @@ -1,7 +1,4 @@ -#!/bin/sh -# -*- sh -*- - -: << =cut +#!/usr/bin/perl -w =head1 NAME @@ -16,12 +13,12 @@ This plugin must run with root privileges /etc/munin/plugin-conf.d/global or other file in that dir must contain: - [fw*] + [fw_*] user root =head1 NOTES -ESTABLISHED+FIN_WAIT+TIME_WAIT+SYN_SENT+UDP is the most interesting +ESTABLISHED+FIN_WAIT+TIME_WAIT+SYN_SENT+UDP are the most interesting connections. The total list also includes SYN_RECV, CLOSE, CLOSE_WAIT, LAST_ACK and @@ -35,30 +32,18 @@ ESTABLISHED. ASSURED is after ACK is seen after SYN_RECV. Therefore ASSURED is plotted but not UNREPLIED. -NATed will almost always be the same as the total - -=head1 BUGS - -=over 4 - -=item full connection table - -The connections tables can run full, but where is the limits found? -If we can find them then we can send warnings to nagios. - -=back +Note that the plugin depends on the netfilter "conntrack" userspace tool. +It comes from http://conntrack-tools.netfilter.org/ =head1 AUTHORS -2004.05.05: Initial version by Nicolai Langfeldt, Linpro AS, Oslo, Norway - -=head2 CONTRIBUTORS +=over -=over 4 +=item 2004.05.05: Initial version by Nicolai Langfeldt, Linpro AS, Oslo, Norway -=item Xavier +=item 2004.05.06: Enhanced to count NATed connections after input from Xavier on munin-users list -2004.05.06: Enhanced to count NATed connections after input from Xavier on munin-users list +=item 2011.09.23: Perl version by Alex Tomlins =back @@ -73,10 +58,30 @@ GPL =cut -case $1 in - config) - - cat < 0, + 'FIN_WAIT' => 0, + 'TIME_WAIT' => 0, + 'SYN_SENT' => 0, + 'UDP' => 0, + 'ASSURED' => 0, + 'NATTED' => 0, + 'TOTAL' => 0 +); +open CMD, "$command|"; +while () { + $state{'TOTAL'} ++; + $state{'UDP'} ++ if /udp /; + $state{'ASSURED'} ++ if /ASSURED/; + if (/tcp \s*\d+\s+\d+\s+(\S+)/) { + $state{$1} ++; + } + if (/src=(\S+)\s+dst=(\S+)\s+sport.*src=(\S+)\s+dst=(\S+)/) { + $state{'NATTED'} ++ if $1 ne $4 or $2 ne $3; + } +} +close CMD; + +print "established.value $state{'ESTABLISHED'}\n"; +print "fin_wait.value $state{'FIN_WAIT'}\n"; +print "time_wait.value $state{'TIME_WAIT'}\n"; +print "syn_sent.value $state{'SYN_SENT'}\n"; +print "udp.value $state{'UDP'}\n"; +print "assured.value $state{'ASSURED'}\n"; +print "nated.value $state{'NATTED'}\n"; +print "total.value $state{'TOTAL'}\n"; diff --git a/cookbooks/munin/recipes/default.rb b/cookbooks/munin/recipes/default.rb index eac718fc0..41d722e0c 100644 --- a/cookbooks/munin/recipes/default.rb +++ b/cookbooks/munin/recipes/default.rb @@ -102,6 +102,8 @@ munin_plugin "entropy" munin_plugin "forks" if node[:kernel][:modules].include?("nf_conntrack") + package "conntrack" + munin_plugin "fw_conntrack" munin_plugin "fw_forwarded_local" else