Projet

Général

Profil

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

root / plugins / mail / mail_connections @ 17f78427

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

1
#!/bin/sh
2
#
3
# Plugin to count the open connections for smtp, pop3 and imap
4
#
5
# Magic markers - optional - used by installation scripts and
6
# munin-config:
7
#
8
#%# family=auto
9
#%# capabilities=autoconf
10

    
11
PORTS="25 smtp SMTP
12
	110 pop3 POP3
13
	143 imap IMAP
14
	465 ssmtp SMTP-SSL
15
	587 submission SMTP (submission)
16
	993 imaps IMAP-SSL
17
	995 pop3s POP3-SSL"
18

    
19
if [ "$1" = "autoconf" ]; then
20
	ports=$(echo "$PORTS" | cut -f 1 -d " ")
21
	for port in $ports; do
22
		netstat -ln | grep -q ":$port " && echo "yes" && exit 0
23
	 done
24
	# no open connections for typical mail ports found
25
        echo "no (no listeners for smtp/pop3/imap ports found)"
26
        exit 0
27
fi
28

    
29
if [ "$1" = "config" ]; then
30
	cat <<EOT
31
graph_title Open mail server connections
32
graph_args --base 1000 -l 0
33
graph_vlabel connections per second
34
graph_category mail
35
EOT
36
	echo "$PORTS" | while read port field label; do
37
		echo "${field}.label $label"
38
		echo "${field}.type DERIVE"
39
		echo "${field}.min 0"
40
	 done
41
	exit 0
42
fi
43

    
44
echo "$PORTS" | while read port field label; do
45
	echo -n "${field}.value "
46
	netstat -n | grep ":$port " | wc -l
47
 done
48