scripts/munin/amavis
Vincent Le Gallic c039058708 Enregistrement des droits d'exécution. Aucune vraie modif.
Darcs n'enregistrait pas les permissions des fichiers.
2013-01-31 05:36:25 +01:00

51 lines
1.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"
echo 'blocked.label Mails bloqués'
echo "blocked.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}`"
echo "blocked.value `grep -c Blocked ${TEMP_FILE}`"