]> git.pld-linux.org Git - packages/cacti-template-snmp_tcp_connection_status.git/commitdiff
- add time_close
authorElan Ruusamäe <glen@pld-linux.org>
Thu, 19 Feb 2009 17:57:16 +0000 (17:57 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
- variables and more cosmetics

Changed files:
    cacti-template-snmp_tcp_connection_status.sh -> 1.4

cacti-template-snmp_tcp_connection_status.sh

index 2d69a69a7f63c3be24bd591fc2e5b6c690360025..56e73d9e1be4ee10a115f3c752a6ba2163824149 100644 (file)
@@ -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 <glen@pld-linux.org>
+
+hostname=$1
+snmp_community=${2:-public}
+timeout=${3:-10}
+retry=5
 
-# convert to use awk by Elan Ruusamäe <glen@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 @@ 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];
This page took 0.11464 seconds and 4 git commands to generate.