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