]> git.pld-linux.org Git - packages/cacti-template-snmp_tcp_connection_status.git/blame - cacti-template-snmp_tcp_connection_status.sh
- add time_close
[packages/cacti-template-snmp_tcp_connection_status.git] / cacti-template-snmp_tcp_connection_status.sh
CommitLineData
ee7d4d10 1#!/bin/sh
da5be338 2#
85c56767 3# get number of tcp connection
85c56767 4# jbrooks@oddelement.com
da5be338
ER
5#
6# modified to use awk and added timeout param by Elan Ruusamäe <glen@pld-linux.org>
7
8hostname=$1
9snmp_community=${2:-public}
10timeout=${3:-10}
11retry=5
85c56767 12
da5be338
ER
13if [ -z "$hostname" ]; then
14 echo >&2 "Usage: $0 HOSTNAME [SNMP_COMMUNITY] [TIMEOUT]"
15 exit 1
16fi
85c56767 17
da5be338 18snmpnetstat -v 2c -r "$retry" -c "$snmp_community" -t "$timeout" -Can -Cp tcp "$hostname" | awk '
ee7d4d10
ER
19 $1 == "tcp" {
20 ss[$4]++;
21 }
22
23 END {
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
da5be338 28 split("time_close listen syn_sent syn_recv established fin_wait1 fin_wait2 closewait lastack closing time_wait", m, " ");
ee7d4d10
ER
29 for (i in t) {
30 s = t[i];
31 k = m[i];
32 printf("%s:%d ", k, ss[s]);
33 }
34}'
This page took 0.076289 seconds and 4 git commands to generate.