amavis 1.13 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#!/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
#

salles's avatar
salles committed
17 18 19
TEMP_FILE=`tempfile`
trap "rm -f ${TEMP_FILE}" EXIT
AMAVIS_LOG=/var/log/mail.info
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
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'
Xavier Lagorce's avatar
Xavier Lagorce committed
38
	echo 'total.label Mails scannés'
salles's avatar
salles committed
39
	echo "total.draw AREA"
Xavier Lagorce's avatar
Xavier Lagorce committed
40
	echo 'virus.label Mails vérolés'
salles's avatar
salles committed
41
	echo "virus.draw AREA"
42 43
	echo 'blocked.label Mails bloqués'
	echo "blocked.draw AREA"
44 45 46
	exit 0
fi

salles's avatar
salles committed
47
logtail -o ${OFFSET} -f ${AMAVIS_LOG} | grep 'amavis\[.*\]:' > ${TEMP_FILE}
48

salles's avatar
salles committed
49 50
echo "total.value `cat ${TEMP_FILE} | wc -l`"
echo "virus.value `grep -c infected ${TEMP_FILE}`"
51
echo "blocked.value `grep -c Blocked  ${TEMP_FILE}`"