scripts/munin/amavis
Antoine Durand-Gasselin 4a68475e34 [wiki-lenny] suppression de static/
darcs-hash:20090314092631-bd074-b01256aeaf71e935851b3ecdbd623eaae8c9e8a1.gz
2009-03-14 10:26:31 +01:00

48 lines
1 KiB
Bash

#!/bin/sh
#
# Plugin to monitor the amavis mail filter.
#
# Usage: Place in /etc/lrrd/client.d/ (or link it there using ln -s)
#
# Parameters understood:
#
# config (required)
# autoconf (optional)
#
# Config variables:
#
# amavislog - file where amavis logs are written
#
TEMP_FILE=`tempfile`
trap "rm -f ${TEMP_FILE}" EXIT
AMAVIS_LOG=/var/log/mail.info
OFFSET=/var/lib/munin/plugin-state/amavis.offset
LOGTAIL=`which logtail`
if [ "$amavislog" ]; then AMAVIS_LOG=$amavislog ; fi
if [ "$1" = "autoconf" ]; then
if [ -f ${AMAVIS_LOG} -a -x ${LOGTAIL} ] ; then
echo yes
exit 0
else
echo no
exit 1
fi
fi
if [ "$1" = "config" ]; then
echo 'graph_title Amavis filter statistics'
echo 'graph_vlabel nb'
echo 'total.label Mails scannés'
echo "total.draw AREA"
echo 'virus.label Mails vérolés'
echo "virus.draw AREA"
exit 0
fi
logtail -o ${OFFSET} -f ${AMAVIS_LOG} | grep 'amavis\[.*\]:' > ${TEMP_FILE}
echo "total.value `cat ${TEMP_FILE} | wc -l`"
echo "virus.value `grep -c infected ${TEMP_FILE}`"