Révision 1bf32bdd
Initial version
| plugins/other/postfix_mailfiltered | ||
|---|---|---|
| 1 |
#!/bin/bash |
|
| 2 |
# |
|
| 3 |
# Plugin to monitor incoming Postfix mail. |
|
| 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 |
LOGTAIL=${logtail:-`which logtail`}
|
|
| 18 |
STATEFILE=/var/lib/munin/plugin-state/postfix_mailfiltered.offset |
|
| 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 Postfix daily filtering' |
|
| 32 |
echo 'graph_order relay rbl helo client sender recipient' |
|
| 33 |
echo 'graph_category mail' |
|
| 34 |
echo 'graph_vlabel Count' |
|
| 35 |
echo 'graph_args --base 1000 -l 0' |
|
| 36 |
echo 'graph_total total' |
|
| 37 |
|
|
| 38 |
echo 'relay.label Relay denied' |
|
| 39 |
echo 'relay.min 1' |
|
| 40 |
echo 'rbl.label RBL blocked' |
|
| 41 |
echo 'rbl.min 1' |
|
| 42 |
echo 'helo.label HELO rejected' |
|
| 43 |
echo 'helo.min 1' |
|
| 44 |
echo 'client.label Client rejected' |
|
| 45 |
echo 'client.min 1' |
|
| 46 |
echo 'sender.label Sender rejected' |
|
| 47 |
echo 'sender.min 1' |
|
| 48 |
echo 'recipient.label Recipient unknown' |
|
| 49 |
echo 'recipient.min 1' |
|
| 50 |
exit 0 |
|
| 51 |
fi |
|
| 52 |
|
|
| 53 |
|
|
| 54 |
relay=u |
|
| 55 |
rbl=U |
|
| 56 |
helo=U |
|
| 57 |
client=U |
|
| 58 |
sender=U |
|
| 59 |
recipient=U |
|
| 60 |
|
|
| 61 |
TEMP_FILE=`mktempfile munin-postfix_filtered.XXXXXX` |
|
| 62 |
|
|
| 63 |
if [ -n "$TEMP_FILE" -a -f "$TEMP_FILE" ] |
|
| 64 |
then |
|
| 65 |
$LOGTAIL ${MAIL_LOG} $STATEFILE | grep "postfix\/smtpd\[[0-9]*\]: NOQUEUE: reject:" > ${TEMP_FILE}
|
|
| 66 |
|
|
| 67 |
relay=`grep 'Relay access denied' ${TEMP_FILE} | wc -l`
|
|
| 68 |
rbl=`grep 'blocked using' ${TEMP_FILE} | wc -l`
|
|
| 69 |
helo=`grep 'Helo command rejected' ${TEMP_FILE} | wc -l`
|
|
| 70 |
client=`grep 'Client host rejected' ${TEMP_FILE} | wc -l`
|
|
| 71 |
sender=`grep 'Sender address rejected' ${TEMP_FILE} | wc -l`
|
|
| 72 |
recipient=`grep 'Recipient address rejected' ${TEMP_FILE} | grep -v "Greylisted" | wc -l`
|
|
| 73 |
|
|
| 74 |
/bin/rm -f $TEMP_FILE |
|
| 75 |
fi |
|
| 76 |
|
|
| 77 |
echo "relay.value ${relay}"
|
|
| 78 |
echo "rbl.value ${rbl}"
|
|
| 79 |
echo "helo.value ${helo}"
|
|
| 80 |
echo "client.value ${client}"
|
|
| 81 |
echo "sender.value ${sender}"
|
|
| 82 |
echo "recipient.value ${recipient}"
|
|
| 83 |
|
|
| 84 |
|
|
Formats disponibles : Unified diff