Projet

Général

Profil

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

root / plugins / postfix / postgrey @ 17f78427

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

1
#!/bin/bash
2
#
3
# Plugin to monitor incoming Postgrey
4
#
5
# Parameters understood:
6
#
7
# 	config   (required)
8
# 	autoconf (optional)
9
#
10

    
11

    
12
mktempfile () {
13
    mktemp -t
14
}
15

    
16
MAIL_LOG=${logfile:-/var/log/mail.log}
17
STATEFILE=$MUNIN_PLUGSTATE/postgrey.offset
18
LOGTAIL=${logtail:-`which logtail`}
19

    
20
if [ "$1" = "autoconf" ]; then
21
        if [ -f "${MAIL_LOG}"  -a -n "${LOGTAIL}" -a -x "${LOGTAIL}" ] ; then
22
		echo yes
23
		exit 0
24
	else
25
		echo no
26
		exit 1
27
	fi
28
fi
29

    
30
if [ "$1" = "config" ]; then
31
	echo 'graph_title Postgrey daily filtering'
32
	echo 'graph_order delayed passed whitelisted'
33
	echo 'graph_category mail'
34
	echo 'graph_vlabel Count'
35
	echo 'graph_scale no'
36

    
37
##	echo 'graph_args --base 1000 -l 0'
38
	echo 'delayed.label delayed'
39
#	echo 'delayed.type DERIVE'
40
	echo 'passed.label passed'
41
#	echo 'passed.type DERIVE'
42
	echo 'whitelisted.label whitelisted'
43
#	echo 'whitelisted.type DERIVE'
44

    
45
        exit 0
46
fi
47

    
48

    
49
delayed=0
50
passed=0
51
whitelisted=0
52

    
53
ARGS=0
54
`$LOGTAIL /etc/hosts 2>/dev/null >/dev/null`
55
if [ $? = 66 ]; then
56
    if [ ! -n "$logtail" ]; then
57
	ARGS=1
58
    fi
59
fi
60

    
61
TEMP_FILE=`mktempfile munin-postgrey.XXXXXX`
62

    
63
if [ -n "$TEMP_FILE" -a -f "$TEMP_FILE" ]
64
then
65
	if [ $ARGS != 0 ]; then
66
	    $LOGTAIL ${MAIL_LOG} $STATEFILE | grep 'post[fix|grey]' > ${TEMP_FILE}
67
	else
68
	    $LOGTAIL ${MAIL_LOG} $STATEFILE | grep 'post[fix|grey]' > ${TEMP_FILE}
69
	fi
70

    
71
	delayed=`grep 'Recipient address rejected.*Greylisted' ${TEMP_FILE} | wc -l`
72
	passed=`grep 'postgrey\[[0-9]*\]: delayed [0-9]* seconds:' ${TEMP_FILE} | wc -l`
73
	whitelisted=`grep 'postgrey\[[0-9]*\]: whitelisted:' ${TEMP_FILE} | wc -l`
74

    
75
	/bin/rm -f $TEMP_FILE
76
fi
77

    
78
echo "delayed.value ${delayed}"
79
echo "passed.value ${passed}"
80
echo "whitelisted.value ${whitelisted}"
81