3 # get number of tcp connection
4 # jbrooks@oddelement.com
6 # modified to use awk and added timeout param by Elan Ruusamäe <glen@pld-linux.org>
9 snmp_community=${2:-public}
13 if [ -z "$hostname" ]; then
14 echo >&2 "Usage: $0 HOSTNAME [SNMP_COMMUNITY] [TIMEOUT]"
18 snmpnetstat -v 2c -r "$retry" -c "$snmp_community" -t "$timeout" -Can -Cp tcp "$hostname" | awk '
24 # socket states from net-snmp-5.4.2.1/apps/snmpnetstat/inet.c
25 split("CLOSED LISTEN SYNSENT SYNRECEIVED ESTABLISHED FINWAIT1 FINWAIT2 CLOSEWAIT LASTACK CLOSING TIMEWAIT", t, " ");
26 # create mapping (duh, why there are different data names used?)
27 # XXX TIMECLOSE missing
28 split("time_close listen syn_sent syn_recv established fin_wait1 fin_wait2 closewait lastack closing time_wait", m, " ");
32 printf("%s:%d ", k, ss[s]);