From e5308456b40258ab382fc0edccf059484fc6639a Mon Sep 17 00:00:00 2001 From: Marki Date: Thu, 11 Nov 2010 14:59:12 +0100 Subject: [PATCH] Initial version --- plugins/other/tcp-states | 54 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100755 plugins/other/tcp-states diff --git a/plugins/other/tcp-states b/plugins/other/tcp-states new file mode 100755 index 00000000..eb093263 --- /dev/null +++ b/plugins/other/tcp-states @@ -0,0 +1,54 @@ +#!/bin/sh +# +# Plugin to monitor TCP states. +# +# Parameters: +# +# config (required) +# autoconf (optional - only used by munin-config) +# +# (C) Marki - count number of connections in each state +# - no LISTEN as we are running netstat without the "-a" option +# +# +# Magic markers (optional - used by munin-config and some installation +# scripts): +#%# family=auto +#%# capabilities=autoconf + + + +if [ "$1" = "autoconf" ]; then + if ( netstat -nt 2>/dev/null >/dev/null ); then + echo yes + exit 0 + else + if [ $? -eq 127 ] + then + echo "no (netstat program not found)" + exit 1 + else + echo no + exit 1 + fi + fi +fi + +if [ "$1" = "config" ]; then + + echo 'graph_title TCP Connection States' + echo 'graph_args -l 0 --base 1000' + echo 'graph_vlabel connections' + echo 'graph_category network' + echo 'graph_period second' + echo 'graph_info This graph shows the TCP connections states of all the network interfaces combined.' + for i in ESTABLISHED SYN_SENT SYN_RECV FIN_WAIT1 FIN_WAIT2 TIME_WAIT CLOSE CLOSE_WAIT LAST_ACK CLOSING; do + echo "$i.label $i" + echo "$i.type GAUGE" + echo "$i.max 32999" + echo "$i.min 0" + done + exit 0 +fi + +netstat -nt | awk '/^tcp/ { states[$6]++ } END { for (idx in states) print idx ".value " states[idx] }'