scripts/munin/amavis
Xavier Lagorce 7438105c0a vers l'utf-8 ...
darcs-hash:20080909193432-b8e4c-8b567852009655f931b00023ebaca090853719dd.gz
2008-09-09 21:34:32 +02:00

48 lines
1 KiB
Bash
Executable file

#!/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}`"