]> git.pld-linux.org Git - packages/cacti-template-snmp_tcp_connection_status.git/blob - cacti-template-snmp_tcp_connection_status.sh
snmp agent: require ss tool directy so iproute2 would not be shadowed by vserver...
[packages/cacti-template-snmp_tcp_connection_status.git] / cacti-template-snmp_tcp_connection_status.sh
1 #!/bin/sh
2 #
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
7 #
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
12
13 PROGRAM=${0##*/}
14
15 hostname=$1
16 snmp_community=${2:-public}
17 timeout=${3:-10}
18 retry=5
19
20 # parse required args
21 if [ -z "$hostname" ]; then
22         echo >&2 "Usage: $PROGRAM HOSTNAME [SNMP_COMMUNITY] [TIMEOUT]"
23         exit 1
24 fi
25
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
This page took 0.066873 seconds and 3 git commands to generate.