X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/7b9ec4b60ee39614d1d083d7220e76b07d2b275f..85451f2406230f9a84becb03f825168ff1ea19c1:/cookbooks/munin/files/default/plugins/fw_conntrack 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";