PluginCat: postfix_messages_hourly.txt

File postfix_messages_hourly.txt, 1.4 kB (added by jintxo, 6 years ago)

Simple parser for Postfix mail.log. Looks for recieved, sent and rejected messages.

Line 
1 #!/bin/sh
2 #
3 #
4 # Script to show postfix stuff
5 #
6 # Parameters understood:
7 #
8 #       config   (required)
9 #       autoconf (optional - used by munin-config)
10 #
11 #
12 # Magic markers (optional - used by munin-config and installation
13 # scripts):
14 #
15 #%# family=auto
16 #%# capabilities=autoconf
17
18 MAXLABEL=20
19
20 if [ "$1" = "autoconf" ]; then
21         echo yes
22         exit 0
23 fi
24
25 if [ "$1" = "config" ]; then
26
27         echo 'graph_title Postfix Mail Counter'
28         echo 'graph_args --base 1000 -l 0'
29         echo 'graph_vlabel Hourly Messages'
30         echo 'recieved.label Incoming'
31         echo 'sent.label Outgoing'
32         echo 'rejecthelo.label Invalid HELO'
33         echo 'rejectsenderdomain.label Bad Sender Domain'
34         echo 'denyrelay.label Relay Denied'
35         exit 0
36 fi
37
38 echo -en "recieved.value "
39 echo $(grep "status=sent (delivered to mailbox)" /var/log/mail.log | grep "`date '+%b %e %H'`" | wc -l)
40 echo -n
41 echo -en "sent.value "
42 echo $(grep "status=sent (250" /var/log/mail.log | grep "`date '+%b %e %H'`" | wc -l)
43 echo -en "rejecthelo.value "
44 echo $(grep "Helo command rejected: Invalid name" /var/log/mail.log | grep "`date '+%b %e %H'`" | wc -l)
45 echo -en "rejectsenderdomain.value "
46 echo $(grep "Sender address rejected: Domain not found" /var/log/mail.log | grep "`date '+%b %e %H'`" | wc -l)
47 echo -en "denyrelay.value "
48 echo $(grep "Relay access denied" /var/log/mail.log | grep "`date '+%b %e %H'`" | wc -l)