Projet

Général

Profil

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

root / plugins / other / postfix_mail_stats @ 1f77869d

Historique | Voir | Annoter | Télécharger (2,01 ko)

1
#!/bin/bash
2
#
3
# Made by Boudewijn Ector, for Boudewijn Ector IT.
4
# Comments can be sent to (boudewijn<AT>boudewijnector'dot'NL)
5
# Loosely based on http://munin.projects.linpro.no/attachment/wiki/PluginCat/postfix_messages_hourly.txt
6
# Script to show postfix stuff
7
#
8
# Modified by Paul Saunders <darac+munin@darac.org.uk>, 10 Dec 2010
9
#
10
# Parameters understood:
11
#
12
#       config   (required)
13
#       autoconf (optional - used by munin-config)
14
#
15
#
16
# Magic markers (optional - used by munin-config and installation
17
# scripts):
18
#
19
#%# family=auto
20
#%# capabilities=autoconf
21

    
22

    
23
LOGFILE=${logfile:-/var/log/maillog}	# Allow user to specify logfile through env.logfile
24
DATE=`date '+%b %e %H'`
25
MAXLABEL=20
26

    
27
if [ "$1" = "autoconf" ]; then
28
	if [[ -r $LOGFILE ]]; then
29
	        echo yes
30
	else
31
		echo no
32
	fi
33
        exit 0
34
fi
35

    
36
if [ "$1" = "config" ]; then
37

    
38
        echo 'graph_title Postfix Mail Counter'
39
        echo 'graph_args --base 1000 -l 0'
40
        echo 'graph_vlabel Hourly Messages'
41
        echo 'recieved.label Delivered'
42
        echo 'sent.label Outgoing'
43
        echo 'rejecthelo.label Invalid HELO'
44
        echo 'rejectsenderdomain.label need FQDN'
45
        echo 'denyrelay.label Relay Denied'
46
	echo 'spamhaus.label Blocked using Spamhaus.org'
47
	echo 'spamcop.label Blocked using Spamcop'
48
        exit 0
49
fi
50

    
51
echo -en "recieved.value "
52
echo $(grep "status=sent (delivered" $LOGFILE | grep "$DATE" | wc -l)
53
echo -n
54
echo -en "sent.value "
55
echo $(grep "status=sent (250" $LOGFILE | grep "$DATE" | wc -l)
56
echo -en "rejecthelo.value "
57
echo $(grep "Helo command rejected: need fully-qualified hostname" $LOGFILE | grep "$DATE" | wc -l)
58
echo -en "rejectsenderdomain.value "
59
echo $(grep "Sender address rejected: Domain not found" $LOGFILE | grep "$DATE" | wc -l)
60

    
61

    
62
echo -en "denyrelay.value "
63
echo $(grep "Relay access denied" $LOGFILE | grep "$DATE" | wc -l)
64
echo -en "spamhaus.value "
65
echo $(grep "blocked using sbl-xbl.spamhaus.org" $LOGFILE | grep "$DATE" | wc -l)
66
echo -en "spamcop.value "
67
echo $(grep "blocked using bl.spamcop.net" $LOGFILE | grep "$DATE" | wc -l)
68