2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00

Minor tidy up and doc fixes

This commit is contained in:
Tim Small 2010-12-10 17:56:56 +01:00 committed by Steve Schnepp
parent f477021dff
commit 58c54d796e

View File

@ -1,20 +1,45 @@
#!/bin/sh
#
# tcp: Plugin to monitor IPV4/6 TCP socket status on a Linux host.
#
# License: GPLv2
#
# Copyright 2009 Tim Small - tim@seoss.co.uk
#
# Parameters supported:
#
# config
# autoconf
#
#
# Magic markers?
#%# family=auto
#%# capabilities=autoconf suggest
: <<EOF
=head1 NAME
tcp - Plugin to monitor IPV4/6 TCP socket status on a Linux host.
=head1 AUTHOR
Copyright 2009 Tim Small <tim@seoss.co.uk>
=head1 LICENSE
GPLv2
=begin comment
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; version 2 dated June, 1991.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA.
=end comment
=head1 MAGIC MARKERS
#%# family=manual
#%# capabilities=autoconf
=cut
EOF
case $1 in
config)
@ -25,7 +50,10 @@ graph_category network
graph_args -l 0
graph_info TCP socket states for the local machine
EOF
for i in established syn_sent syn_recv fin_wait1 fin_wait2 time_wait close close_wait last_ack listen closing
for i in established syn_sent syn_recv fin_wait1 \
fin_wait2 time_wait close close_wait last_ack \
listen closing
do
echo ${i}.label $i
echo ${i}.draw LINE2
@ -35,7 +63,8 @@ EOF
exit 0
;;
autoconf)
if [ -f /proc/net/tcp -o -f /proc/net/tcp6 ] ; then
if [ -f /proc/net/tcp -o -f /proc/net/tcp6 ]
then
echo yes
exit 0
else
@ -47,17 +76,21 @@ esac
# See #include <netinet/tcp.h>
cat /proc/net/tcp* | awk '
BEGIN { STATE["01"]=STATE["02"]=STATE["03"]=STATE["04"]=STATE["05"]=STATE["06"]=STATE["07"]=STATE["08"]=STATE["09"]=STATE["0A"]=STATE["0B"]=0; }
match ($4, /0[0-9A-B]/) { STATE[$4]++; }
END { print "established.value " STATE["01"];
print "syn_sent.value " STATE["02"];
print "syn_recv.value " STATE["03"];
print "fin_wait1.value " STATE["04"];
print "fin_wait2.value " STATE["05"];
print "time_wait.value " STATE["06"];
print "close.value " STATE["07"];
print "close_wait.value " STATE["08"];
print "last_ack.value " STATE["09"];
print "listen.value " STATE["0A"];
print "closing.value " STATE["0B"];
match ($4, /0[0-9A-B]/) {
STATE[$4]++;
}
END {
printf "established.value %d\n", STATE["01"];
printf "syn_sent.value %d\n", STATE["02"];
printf "syn_recv.value %d\n", STATE["03"];
printf "fin_wait1.value %d\n", STATE["04"];
printf "fin_wait2.value %d\n", STATE["05"];
printf "time_wait.value %d\n", STATE["06"];
printf "close.value %d\n", STATE["07"];
printf "close_wait.value %d\n", STATE["08"];
printf "last_ack.value %d\n", STATE["09"];
printf "listen.value %d\n", STATE["0A"];
printf "closing.value %d\n", STATE["0B"];
}'