4 # Description: Munin plugin to monitor amavisd-new mail-filter
5 # Based on a plugin authored by Fili Wiese that may be found on
6 # http://muninexchange.projects.linpro.no/ under the name
7 # amavis-debian with some addition to show all type of amavis
8 # mails statuses: Total, Clean, Spammy, spam, Infected, Banned,
11 # Parameters understood:
16 # AMAVIS_LOG - file where amavis logs are written
17 # STATEFILE - file which is needed to keep track of AMAVIS_LOG
18 # LOGTAIL - location of logtail
21 # Copyright (C) 2010 Emmanuel Lacour <elacour@home-dn.net>
23 # This program is free software; you can redistribute it and/or modify
24 # it under the terms of the GNU General Public License as published by
25 # the Free Software Foundation; either version 2 of the License, or
26 # (at your option) any later version.
28 # This program is distributed in the hope that it will be useful,
29 # but WITHOUT ANY WARRANTY; without even the implied warranty of
30 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 # GNU General Public License for more details.
33 # You should have received a copy of the GNU General Public License
34 # along with this program; if not, write to the Free Software
35 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,
39 AMAVIS_LOG=${logfile:-/var/log/mail.log}
40 STATEFILE=/var/lib/munin/plugin-state/amavisd-new.offset
41 LOGTAIL=${logtail:-`which logtail`}
48 if [ "$1" = "autoconf" ]; then
49 if [ -f "${AMAVIS_LOG}" -a -n "${LOGTAIL}" -a -x "${LOGTAIL}" -a -n "${BC}" -a -x "${BC}" ] ; then
58 if [ "$1" = "config" ]; then
59 echo 'graph_title Amavisd-new statistics'
60 echo 'graph_category amavis'
61 echo 'graph_order total clean spammy spam infected banned badh other'
62 echo 'graph_vlabel Mails'
64 echo 'total.info Total count of emails'
65 echo 'total.label Total'
66 echo 'total.draw AREA'
67 echo 'clean.info Count of clean emails'
68 echo 'clean.label Clean'
69 echo 'clean.draw LINE1'
70 echo 'spammy.info Count of spams emails (tag2 level)'
71 echo 'spammy.label Spammy'
72 echo 'spammy.draw LINE1'
73 echo 'spam.info Count of spams emails (kill level)'
74 echo 'spam.label Spam'
75 echo 'spam.draw LINE1'
76 echo 'infected.info Count of infected emails (virus)'
77 echo 'infected.label Infected'
78 echo 'infected.draw LINE1'
79 echo 'banned.info Count of emails with banned files'
80 echo 'banned.label Banned'
81 echo 'banned.draw LINE1'
82 echo 'badh.info Count of emails with bad headers'
83 echo 'badh.label Bad-header'
84 echo 'badh.draw LINE1'
85 echo 'other.info Count of emails that dont fit other categories'
86 echo 'other.label Others'
87 echo 'other.draw LINE1'
101 `$LOGTAIL -f /etc/hosts 2>/dev/null >/dev/null`
103 if [ ! -n "$logtail" ]; then
108 TEMP_FILE=$(mktempfile munin-amavisd-new.XXXXXX)
110 if [ -n "$TEMP_FILE" -a -f "$TEMP_FILE" ]
112 if [ $ARGS != 0 ]; then
113 $LOGTAIL -f ${AMAVIS_LOG} -o $STATEFILE | grep 'amavis\[.*\]:' | grep -v 'TIMED OUT' > ${TEMP_FILE}
115 $LOGTAIL -f ${AMAVIS_LOG} -o $STATEFILE | grep 'amavis\[.*\]:' | grep -v 'TIMED OUT' > ${TEMP_FILE}
117 total=$(wc -l < ${TEMP_FILE})
118 clean=$(grep -Ec '(Passed|Blocked) CLEAN' ${TEMP_FILE})
119 infected=$(grep -Ec '(Passed|Blocked) INFECTED' ${TEMP_FILE})
120 spammy=$(grep -Ec '(Passed|Blocked) SPAMMY' ${TEMP_FILE})
121 spam=$(grep -E '(Passed|Blocked) SPAM' ${TEMP_FILE} | grep -Ev '(Passed|Blocked) SPAMMY' | wc -l)
122 banned=$(grep -Ec '(Passed|Blocked) BANNED' ${TEMP_FILE})
123 badh=$(grep -Ec '(Passed|Blocked) BAD-HEADER' ${TEMP_FILE})
124 other=$(echo ${total}-${clean}-${infected}-${spammy}-${spam}-${banned}-${badh} | ${BC})
126 /bin/rm -f $TEMP_FILE
130 echo "clean.value ${clean}"
131 echo "infected.value ${infected}"
132 echo "spammy.value ${spammy}"
133 echo "spam.value ${spam}"
134 echo "banned.value ${banned}"
135 echo "badh.value ${badh}"
136 echo "other.value ${other}"
137 echo "total.value ${total}"