]>
Commit | Line | Data |
---|---|---|
ee7d4d10 | 1 | #!/bin/sh |
da5be338 | 2 | # |
387ee645 ER |
3 | # get number of tcp connections |
4 | # original code and xml templates by: <jbrooks@oddelement.com> | |
5 | # history: | |
6 | # http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/cacti-template-snmp_tcp_connection_status/cacti-template-snmp_tcp_connection_status.sh | |
da5be338 | 7 | # |
e0ca6b25 ER |
8 | # Modified to use snmpget via aggregate program in snmpd side by Elan Ruusamäe <glen@pld-linux.org>, 2009-10-14 |
9 | # | |
10 | # To use this script, you must define in your snmpd.local.conf: | |
11 | # extend .1.3.6.1.4.1.16606.1 tcpstat /usr/lib/snmpd-agent-tcpstat | |
387ee645 ER |
12 | |
13 | PROGRAM=${0##*/} | |
14 | ||
da5be338 ER |
15 | hostname=$1 |
16 | snmp_community=${2:-public} | |
17 | timeout=${3:-10} | |
18 | retry=5 | |
85c56767 | 19 | |
42bd8d07 ER |
20 | # parse required args |
21 | if [ -z "$hostname" ]; then | |
20dc28d5 | 22 | echo >&2 "Usage: $PROGRAM HOSTNAME [SNMP_COMMUNITY] [TIMEOUT]" |
da5be338 ER |
23 | exit 1 |
24 | fi | |
85c56767 | 25 | |
e0ca6b25 ER |
26 | # Use registered OID, http://www.oid-info.com/get/1.3.6.1.4.1.16606: |
27 | oidbase=.1.3.6.1.4.1.16606.1 | |
28 | oidextend=3.1.1 | |
29 | oidcmd='"tcpstat"' | |
30 | oid=$oidbase.$oidextend.$oidcmd | |
31 | ||
32 | out=$(snmpget -v2c -Onqv -c "$snmp_community" -t "$timeout" "$hostname" "$oid") || exit $? | |
33 | # strip quotes | |
34 | out=${out#\"} out=${out%\"} | |
35 | echo $out |