From da5be338ad095caa0be01e19dd8992bb737b370f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Elan=20Ruusam=C3=A4e?= Date: Thu, 19 Feb 2009 17:57:16 +0000 Subject: [PATCH] - add time_close - variables and more cosmetics Changed files: cacti-template-snmp_tcp_connection_status.sh -> 1.4 --- cacti-template-snmp_tcp_connection_status.sh | 21 +++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/cacti-template-snmp_tcp_connection_status.sh b/cacti-template-snmp_tcp_connection_status.sh index 2d69a69..56e73d9 100644 --- a/cacti-template-snmp_tcp_connection_status.sh +++ b/cacti-template-snmp_tcp_connection_status.sh @@ -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@oddelement.com +# +# modified to use awk and added timeout param by Elan Ruusamäe + +hostname=$1 +snmp_community=${2:-public} +timeout=${3:-10} +retry=5 -# convert to use awk by Elan Ruusamäe +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 @@ snmpnetstat -v 2c -c "$2" -Can -Cp tcp "$1" | awk ' 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]; -- 2.44.0