2008-12-19 11:06:52 +01:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# Plugin to monitor Amavis virus and spam statistics.
|
|
|
|
#
|
2018-08-02 02:03:42 +02:00
|
|
|
#
|
2008-12-19 11:06:52 +01:00
|
|
|
# Based on a routine by William Towle
|
|
|
|
# Uncomment the cdef lines to convert the graph to mails/minute
|
|
|
|
# Comment out the line "total.graph no" to show the total on the graph. This may not be aesthetically pleasing.
|
|
|
|
#
|
|
|
|
# Parameters understood:
|
|
|
|
#
|
|
|
|
# config (required)
|
|
|
|
# autoconf (optional)
|
|
|
|
#
|
|
|
|
|
|
|
|
# requires logtail
|
|
|
|
|
|
|
|
LOGDIR=${logdir:-/var/log/amavis}
|
|
|
|
MAIL_LOG=$LOGDIR/${logfile:-amavisd.log}
|
|
|
|
LOGTAIL=${logtail:-`which logtail`}
|
2017-04-18 23:32:55 +02:00
|
|
|
STATEFILE=$MUNIN_PLUGSTATE/amavis.offset
|
2008-12-19 11:06:52 +01:00
|
|
|
|
|
|
|
if [ "$1" = "autoconf" ]; then
|
|
|
|
if [ -f "${MAIL_LOG}" -a -n "${LOGTAIL}" -a -x "${LOGTAIL}" ] ; then
|
|
|
|
echo yes
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
echo no
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$1" = "config" ]; then
|
|
|
|
echo 'graph_title Amavis message filtering'
|
|
|
|
|
2017-02-20 18:32:37 +01:00
|
|
|
echo 'graph_category antivirus'
|
2008-12-19 11:06:52 +01:00
|
|
|
echo 'graph_vlabel Mails per minute'
|
|
|
|
echo 'graph_args --base 1000 -l 0'
|
|
|
|
|
|
|
|
echo 'graph_order clean p_spam b_spam virus total'
|
2018-08-02 02:03:42 +02:00
|
|
|
|
2008-12-19 11:06:52 +01:00
|
|
|
echo 'clean.min 0'
|
|
|
|
echo 'clean.type ABSOLUTE'
|
|
|
|
#echo 'clean.cdef clean,60,*'
|
|
|
|
echo 'clean.draw AREA'
|
|
|
|
|
|
|
|
for i in p_spam b_spam virus;
|
|
|
|
do
|
|
|
|
echo "$i.min 0"
|
|
|
|
echo "$i.type ABSOLUTE";
|
|
|
|
#echo "$i.cdef $i,60,*";
|
|
|
|
echo "$i.draw STACK";
|
|
|
|
done
|
|
|
|
|
|
|
|
echo 'clean.label Passed CLEAN'
|
|
|
|
echo 'p_spam.label Passed SPAMMY'
|
|
|
|
echo 'b_spam.label Blocked SPAMMY'
|
|
|
|
echo 'virus.label Blocked INFECTED'
|
|
|
|
echo 'total.label Total'
|
|
|
|
echo 'total.graph no'
|
|
|
|
echo 'clean.colour 00ff00'
|
|
|
|
echo 'p_spam.colour ff4000'
|
|
|
|
echo 'b_spam.colour ff0000'
|
|
|
|
echo 'virus.colour 000000'
|
|
|
|
exit 0
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$LOGTAIL ${MAIL_LOG} $STATEFILE | \
|
2018-08-02 02:03:42 +02:00
|
|
|
awk 'BEGIN { na= 0; nb= 0; nc= 0; nd= 0; total= 0 }
|
|
|
|
|
|
|
|
{
|
2008-12-19 11:06:52 +01:00
|
|
|
|
2018-08-02 02:03:42 +02:00
|
|
|
if (index($0, "Passed CLEAN")) { na++ ; total++ }
|
|
|
|
else if (index($0, "Passed SPAMMY")) { nb++ ; total++ }
|
2008-12-19 11:06:52 +01:00
|
|
|
else if (index($0, "Blocked SPAMMY")) { nc++ ; total++ }
|
|
|
|
else if (index($0, "INFECTED")) { nd++ ; total++ }
|
|
|
|
}
|
|
|
|
END { print "clean.value " na"\np_spam.value " nb"\nb_spam.value " nc"\nvirus.value " nd"\ntotal.value " total }'
|
|
|
|
|
|
|
|
|