SOURCES: cacti-plugin-snmp_tcp_connection_status.sh - add time_close - vari...

glen glen at pld-linux.org
Thu Feb 19 18:57:22 CET 2009


Author: glen                         Date: Thu Feb 19 17:57:22 2009 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- add time_close
- variables and more cosmetics

---- Files affected:
SOURCES:
   cacti-plugin-snmp_tcp_connection_status.sh (1.3 -> 1.4) 

---- Diffs:

================================================================
Index: SOURCES/cacti-plugin-snmp_tcp_connection_status.sh
diff -u SOURCES/cacti-plugin-snmp_tcp_connection_status.sh:1.3 SOURCES/cacti-plugin-snmp_tcp_connection_status.sh:1.4
--- SOURCES/cacti-plugin-snmp_tcp_connection_status.sh:1.3	Wed Jan 21 15:18:30 2009
+++ SOURCES/cacti-plugin-snmp_tcp_connection_status.sh	Thu Feb 19 18:57:16 2009
@@ -1,14 +1,21 @@
 #!/bin/sh
+#
 # get number of tcp connection
-# $1 = hostname
-# $2 = snmp community
-
-# lots of ways to do this with more style... ;)
 # jbrooks at oddelement.com
+#
+# modified to use awk and added timeout param by Elan Ruusamäe <glen at pld-linux.org>
+
+hostname=$1
+snmp_community=${2:-public}
+timeout=${3:-10}
+retry=5
 
-# convert to use awk by Elan Ruusamäe <glen at pld-linux.org>
+if [ -z "$hostname" ]; then
+	echo >&2 "Usage: $0 HOSTNAME [SNMP_COMMUNITY] [TIMEOUT]"
+	exit 1
+fi
 
-snmpnetstat -v 2c -c "$2" -Can -Cp tcp "$1" | awk '
+snmpnetstat -v 2c -r "$retry" -c "$snmp_community" -t "$timeout" -Can -Cp tcp "$hostname" | awk '
 	$1 == "tcp" {
 		ss[$4]++;
 	}
@@ -18,7 +25,7 @@
 		split("CLOSED LISTEN SYNSENT SYNRECEIVED ESTABLISHED FINWAIT1 FINWAIT2 CLOSEWAIT LASTACK CLOSING TIMEWAIT", t, " ");
 		# create mapping (duh, why there are different data names used?)
 		# XXX TIMECLOSE missing
-		split("closed listen syn_sent syn_recv established fin_wait1 fin_wait2 closewait lastack closing time_wait", m, " ");
+		split("time_close listen syn_sent syn_recv established fin_wait1 fin_wait2 closewait lastack closing time_wait", m, " ");
 		for (i in t) {
 			s = t[i];
 			k = m[i];
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/SOURCES/cacti-plugin-snmp_tcp_connection_status.sh?r1=1.3&r2=1.4&f=u



More information about the pld-cvs-commit mailing list