- Repository
- Munin (contrib)
- Last change
- 2020-03-26
- Graph Categories
- Keywords
- Language
- Bash
amavis_awk
Sadly there is no documentation for this plugin.
#!/bin/bash
#
# Plugin to monitor Amavis virus and spam statistics.
#
#
# 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`}
STATEFILE=$MUNIN_PLUGSTATE/amavis.offset
if [ "$1" = "autoconf" ]; then
if [ -f "${MAIL_LOG}" -a -n "${LOGTAIL}" -a -x "${LOGTAIL}" ] ; then
echo yes
else
echo no
fi
exit 0
fi
if [ "$1" = "config" ]; then
echo 'graph_title Amavis message filtering'
echo 'graph_category antivirus'
echo 'graph_vlabel Mails per minute'
echo 'graph_args --base 1000 -l 0'
echo 'graph_order clean p_spam b_spam virus total'
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 | \
awk 'BEGIN { clean_count=0; passed_spam_count=0; blocked_spam_count=0; infected_count=0; total=0 }
{
if (index($0, "Passed CLEAN")) { clean_count++ ; total++ }
else if (index($0, "Passed SPAMMY")) { passed_spam_count++ ; total++ }
else if (index($0, "Blocked SPAMMY")) { blocked_spam_count++ ; total++ }
else if (index($0, "INFECTED")) { infected_count++ ; total++ }
}
END { print "clean.value " clean_count"\np_spam.value " passed_spam_count"\nb_spam.value " blocked_spam_count"\nvirus.value " infected_count"\ntotal.value " total }'