]> git.pld-linux.org Git - packages/cacti-template-snmp_tcp_connection_status.git/blob - cacti-template-snmp_tcp_connection_status.sh
2d69a69a7f63c3be24bd591fc2e5b6c690360025
[packages/cacti-template-snmp_tcp_connection_status.git] / cacti-template-snmp_tcp_connection_status.sh
1 #!/bin/sh
2 # get number of tcp connection
3 # $1 = hostname
4 # $2 = snmp community
5
6 # lots of ways to do this with more style... ;)
7 # jbrooks@oddelement.com
8
9 # convert to use awk by Elan Ruusamäe <glen@pld-linux.org>
10
11 snmpnetstat -v 2c -c "$2" -Can -Cp tcp "$1" | awk '
12         $1 == "tcp" {
13                 ss[$4]++;
14         }
15
16         END {
17                 # socket states from net-snmp-5.4.2.1/apps/snmpnetstat/inet.c
18                 split("CLOSED LISTEN SYNSENT SYNRECEIVED ESTABLISHED FINWAIT1 FINWAIT2 CLOSEWAIT LASTACK CLOSING TIMEWAIT", t, " ");
19                 # create mapping (duh, why there are different data names used?)
20                 # XXX TIMECLOSE missing
21                 split("closed listen syn_sent syn_recv established fin_wait1 fin_wait2 closewait lastack closing time_wait", m, " ");
22                 for (i in t) {
23                         s = t[i];
24                         k = m[i];
25                         printf("%s:%d ", k, ss[s]);
26                 }
27 }'
This page took 0.064097 seconds and 2 git commands to generate.