From f6ae9cd757af91a81a5e67a4e97ffd4e68c0184e Mon Sep 17 00:00:00 2001 From: master_255 Date: Tue, 13 Apr 2010 12:27:37 +0200 Subject: [PATCH] Initial version --- plugins/other/sockstat | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 plugins/other/sockstat diff --git a/plugins/other/sockstat b/plugins/other/sockstat new file mode 100755 index 00000000..ad78669b --- /dev/null +++ b/plugins/other/sockstat @@ -0,0 +1,42 @@ +#!/bin/sh +# + +PATH=/bin:/usr/bin + +if [ "$1" = "autoconf" ]; then + echo yes + exit 0 +fi + +DAEMONS=`sockstat | awk '{print substr($0, 1, 8)}' | sort | uniq` + +if [ "$1" = "config" ]; then + echo 'graph_title Connections' + echo 'graph_vlabel Connections' + echo 'graph_noscale true' + echo 'graph_category network' + echo 'graph_info This graph shows connections load.' + + for D in $DAEMONS + do + echo "_$D.label $D" + done + + echo "_TOTAL.label TOTAL" + + exit 0 +fi + +VALUES=`sockstat | awk '{print substr($0, 1, 8)}' | sort | uniq -c` +NUM=1 + +for D in $DAEMONS +do + echo -n "_$D.value " + VAL=`echo $VALUES | cut -d ' ' -f $NUM` + echo $VAL +NUM=$(($NUM + 2)) +done + +echo -n "_TOTAL.value " +sockstat | wc -l