]> git.pld-linux.org Git - packages/cacti-template-snmp_tcp_connection_status.git/commitdiff
- snmpget only
authorElan Ruusamäe <glen@pld-linux.org>
Fri, 23 Oct 2009 14:12:38 +0000 (14:12 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    cacti-template-snmp_tcp_connection_status.sh -> 1.6

cacti-template-snmp_tcp_connection_status.sh

index 21afdbbe4c9fd58a6676fbf015aa255ae654104c..74a2eb0af3c6e20b46c45ece1ab7c2cc213b1250 100644 (file)
@@ -9,59 +9,18 @@
 
 PROGRAM=${0##*/}
 
-# parse command line args
-t=$(getopt -o o: -n "$PROGRAM" -- "$@")
-[ $? != 0 ] && exit $?
-eval set -- "$t"
-
-while :; do
-       case "$1" in
-       -o)
-               snmpget=$2
-               shift
-       ;;
-       --)
-               shift
-               break
-       ;;
-       *)
-               echo 2>&1 "$PROGRAM: Internal error: [$1] not recognized!"
-               exit 1
-       ;;
-       esac
-       shift
-done
-
 hostname=$1
 snmp_community=${2:-public}
 timeout=${3:-10}
 retry=5
+oid=.1.3.6.1.4.1.16606.1.3.1.1.7.116.99.112.115.116.97.116
 
+# handle case when template was imported with <> getting lost
 if [ -z "$hostname" -o "$hostname" = "hostcommunity" ]; then # WTF
-       echo >&2 "Usage: $0 HOSTNAME [SNMP_COMMUNITY] [TIMEOUT]"
+       echo >&2 "Usage: $PROGRAM HOSTNAME [SNMP_COMMUNITY] [TIMEOUT]"
        exit 1
 fi
 
-if [ "$snmpget" ]; then
-       local out
-       out=$(snmpget -v2c -On -c "$snmp_community" -t "$timeout" "$hostname" "$snmpget") || exit $?
-       echo ${out#.*STRING: }
-       exit 0
-fi
-
-snmpnetstat -v 2c -r "$retry" -c "$snmp_community" -t "$timeout" -Can -Cp tcp "$hostname" | awk '
-       $1 == "tcp" {
-               ss[$4]++;
-       }
-
-               # socket states from net-snmp-5.4.2.1/apps/snmpnetstat/inet.c
-               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("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];
-                       printf("%s:%d ", k, ss[s]);
-               }
-}'
+out=$(snmpget -v2c -On -c "$snmp_community" -t "$timeout" "$hostname" "$snmpget") || exit $?
+echo ${out#.*STRING: }
+exit 0
This page took 0.152512 seconds and 4 git commands to generate.