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 #!/bin/sh
#
# tcp: Plugin to monitor IPV4/6 TCP socket status on a Linux host. : <<EOF
#
# License: GPLv2 =head1 NAME
#
# Copyright 2009 Tim Small - tim@seoss.co.uk tcp - Plugin to monitor IPV4/6 TCP socket status on a Linux host.
#
# Parameters supported: =head1 AUTHOR
#
# config Copyright 2009 Tim Small <tim@seoss.co.uk>
# autoconf
# =head1 LICENSE
#
# Magic markers? GPLv2
#%# family=auto
#%# capabilities=autoconf suggest =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 case $1 in
config) config)
@ -25,39 +50,47 @@ graph_category network
graph_args -l 0 graph_args -l 0
graph_info TCP socket states for the local machine graph_info TCP socket states for the local machine
EOF EOF
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
echo ${i}.info Sockets in state $i
done
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
echo ${i}.info Sockets in state $i
done
exit 0 exit 0
;; ;;
autoconf) autoconf)
if [ -f /proc/net/tcp -o -f /proc/net/tcp6 ] ; then if [ -f /proc/net/tcp -o -f /proc/net/tcp6 ]
echo yes then
exit 0 echo yes
else exit 0
echo no else
exit 1 echo no
fi exit 1
fi
esac esac
# See #include <netinet/tcp.h> # See #include <netinet/tcp.h>
cat /proc/net/tcp* | awk ' 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]++; } match ($4, /0[0-9A-B]/) {
END { print "established.value " STATE["01"]; STATE[$4]++;
print "syn_sent.value " STATE["02"]; }
print "syn_recv.value " STATE["03"];
print "fin_wait1.value " STATE["04"]; END {
print "fin_wait2.value " STATE["05"]; printf "established.value %d\n", STATE["01"];
print "time_wait.value " STATE["06"]; printf "syn_sent.value %d\n", STATE["02"];
print "close.value " STATE["07"]; printf "syn_recv.value %d\n", STATE["03"];
print "close_wait.value " STATE["08"]; printf "fin_wait1.value %d\n", STATE["04"];
print "last_ack.value " STATE["09"]; printf "fin_wait2.value %d\n", STATE["05"];
print "listen.value " STATE["0A"]; printf "time_wait.value %d\n", STATE["06"];
print "closing.value " STATE["0B"]; 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"];
}'