Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / network / tcp-states @ dd4afac8

Historique | Voir | Annoter | Télécharger (1,22 ko)

1 e5308456 Marki
#!/bin/sh
2
#
3
# Plugin to monitor TCP states.
4
#
5
# Parameters:
6
#
7
# 	config   (required)
8
# 	autoconf (optional - only used by munin-config)
9
#
10
# (C) Marki - count number of connections in each state
11
#           - no LISTEN as we are running netstat without the "-a" option
12
#
13
#
14
# Magic markers (optional - used by munin-config and some installation
15
# scripts):
16
#%# family=auto
17
#%# capabilities=autoconf
18
19
20
21
if [ "$1" = "autoconf" ]; then
22
	if ( netstat -nt 2>/dev/null >/dev/null ); then
23
		echo yes
24
		exit 0
25
	else
26
		if [ $? -eq 127 ]
27
		then
28
			echo "no (netstat program not found)"
29
			exit 1
30
		else
31
			echo no
32
			exit 1
33
		fi
34
	fi
35
fi
36
37
if [ "$1" = "config" ]; then
38
39
	echo 'graph_title TCP Connection States'
40
	echo 'graph_args -l 0 --base 1000'
41
	echo 'graph_vlabel connections'
42
	echo 'graph_category network'
43
	echo 'graph_period second'
44
	echo 'graph_info This graph shows the TCP connections states of all the network interfaces combined.'
45
	for i in ESTABLISHED SYN_SENT SYN_RECV FIN_WAIT1 FIN_WAIT2 TIME_WAIT CLOSE CLOSE_WAIT LAST_ACK CLOSING; do
46
	  echo "$i.label $i"
47
	  echo "$i.type GAUGE"
48
	  echo "$i.max 32999"
49
	  echo "$i.min 0"
50
	done
51
	exit 0
52
fi
53
54
netstat -nt | awk '/^tcp/ { states[$6]++ } END { for (idx in states) print idx ".value " states[idx] }'