Révision 9fb241c4
Initial version
| plugins/other/postfix_filtered_awk | ||
|---|---|---|
| 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 |
# requires logtail |
|
| 12 |
|
|
| 13 |
# If you are using a postfix policy daemon (such as policyd) to track certain block conditions, place a line |
|
| 14 |
# in your /etc/munin/plugin-conf.d/munin-node like: |
|
| 15 |
# |
|
| 16 |
# [postfix_filtered] |
|
| 17 |
# env.policy my policy string |
|
| 18 |
# |
|
| 19 |
# When env.policy is set, this plugin will match the string you supply as env.policy and return the number of instances |
|
| 20 |
# of that string as an output called "policy.value". |
|
| 21 |
# |
|
| 22 |
# If you are NOT using a postfix policy daemon, as above, use the line |
|
| 23 |
# |
|
| 24 |
# [postfix_filtered] |
|
| 25 |
# env.policy none |
|
| 26 |
# |
|
| 27 |
# and this plugin will suppress output of policy.value |
|
| 28 |
|
|
| 29 |
POLICY='' |
|
| 30 |
[ "${policy}" = 'none' ] || POLICY="${policy}"
|
|
| 31 |
export POLICY |
|
| 32 |
|
|
| 33 |
|
|
| 34 |
|
|
| 35 |
LOGDIR=${logdir:-/var/log/mail}
|
|
| 36 |
MAIL_LOG=$LOGDIR/${logfile:-info}
|
|
| 37 |
LOGTAIL=${logtail:-`which logtail`}
|
|
| 38 |
STATEFILE=/var/lib/munin/plugin-state/postfix_mailfiltered_test.offset |
|
| 39 |
|
|
| 40 |
if [ "$1" = "autoconf" ]; then |
|
| 41 |
if [ -f "${MAIL_LOG}" -a -n "${LOGTAIL}" -a -x "${LOGTAIL}" ] ; then
|
|
| 42 |
echo yes |
|
| 43 |
exit 0 |
|
| 44 |
else |
|
| 45 |
echo no |
|
| 46 |
exit 1 |
|
| 47 |
fi |
|
| 48 |
fi |
|
| 49 |
|
|
| 50 |
if [ "$1" = "config" ]; then |
|
| 51 |
echo 'graph_title Postfix message filtering' |
|
| 52 |
|
|
| 53 |
echo 'graph_category mail' |
|
| 54 |
echo 'graph_vlabel Mails per second' |
|
| 55 |
# echo 'graph_args --base 1000 --logarithmic' |
|
| 56 |
echo 'graph_args --base 1000 -l 0' |
|
| 57 |
|
|
| 58 |
if [ -z "$POLICY" ] |
|
| 59 |
then |
|
| 60 |
echo 'graph_order rbl helo client sender recipient relay allowed' |
|
| 61 |
|
|
| 62 |
else |
|
| 63 |
echo 'graph_order rbl policy helo client sender recipient relay allowed' |
|
| 64 |
echo 'policy.label policy blocked' |
|
| 65 |
echo 'policy.min 0' |
|
| 66 |
echo 'policy.draw LINE1' |
|
| 67 |
echo 'policy.type ABSOLUTE' |
|
| 68 |
fi |
|
| 69 |
|
|
| 70 |
|
|
| 71 |
echo 'allowed.draw LINE2' |
|
| 72 |
echo 'allowed.type ABSOLUTE' |
|
| 73 |
echo 'allowed.colour 00ff00' |
|
| 74 |
echo 'rbl.draw LINE2' |
|
| 75 |
echo 'rbl.type ABSOLUTE' |
|
| 76 |
echo 'rbl.colour 1010ff' |
|
| 77 |
|
|
| 78 |
for i in helo client sender recipient relay; |
|
| 79 |
do |
|
| 80 |
echo "$i.min 0" |
|
| 81 |
echo "$i.type ABSOLUTE" |
|
| 82 |
echo "$i.draw LINE1"; |
|
| 83 |
done |
|
| 84 |
|
|
| 85 |
echo 'allowed.label allowed' |
|
| 86 |
echo 'rbl.label RBL blocked' |
|
| 87 |
echo 'helo.label HELO rejected' |
|
| 88 |
echo 'client.label Client rejected' |
|
| 89 |
echo 'sender.label Sender rejected' |
|
| 90 |
echo 'recipient.label recipient unknown' |
|
| 91 |
echo 'relay.label relay denied' |
|
| 92 |
|
|
| 93 |
exit 0 |
|
| 94 |
|
|
| 95 |
fi |
|
| 96 |
|
|
| 97 |
|
|
| 98 |
|
|
| 99 |
|
|
| 100 |
$LOGTAIL ${MAIL_LOG} $STATEFILE | \
|
|
| 101 |
awk 'BEGIN { na= 0; nb= 0; nc= 0; nd= 0; ne= 0; nf= 0; ng= 0; nh= 0 ; st= ENVIRON["POLICY"] }
|
|
| 102 |
|
|
| 103 |
{
|
|
| 104 |
if (index($0, "queued as")) { na++ }
|
|
| 105 |
else if (index($0, "Relay access denied")) { nb++ }
|
|
| 106 |
else if (index($0, "blocked using")) { nc++ }
|
|
| 107 |
else if (index($0, "Helo command rejected")) { nd++ }
|
|
| 108 |
else if (index($0, "Client host rejected")) { ne++ }
|
|
| 109 |
else if (index($0, "Sender address rejected")) { nf++ }
|
|
| 110 |
else if (index($0, "Recipient address rejected")) { ng++ }
|
|
| 111 |
else if (st && index($0, st)) { nh++ }
|
|
| 112 |
} |
|
| 113 |
END { print "allowed.value " na"\nrelay.value " nb"\nrbl.value " nc"\nhelo.value " nd"\nclient.value " ne"\nsender.value " nf"\nrecipient.value " ng ; if (st) print "policy.value " nh }'
|
|
| 114 |
|
|
| 115 |
|
|
Formats disponibles : Unified diff