Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / amavis / amavis_awk @ ba89ed20

Historique | Voir | Annoter | Télécharger (2,09 ko)

1
#!/bin/bash
2
#
3
# Plugin to monitor Amavis virus and spam statistics.
4
#
5
#
6
# Based on a routine by William Towle
7
# Uncomment the cdef lines to convert the graph to mails/minute
8
# Comment out the line "total.graph no" to show the total on the graph. This may not be aesthetically pleasing.
9
#
10
# Parameters understood:
11
#
12
# 	config   (required)
13
# 	autoconf (optional)
14
#
15

    
16
# requires logtail
17

    
18
LOGDIR=${logdir:-/var/log/amavis}
19
MAIL_LOG=$LOGDIR/${logfile:-amavisd.log}
20
LOGTAIL=${logtail:-`which logtail`}
21
STATEFILE=$MUNIN_PLUGSTATE/amavis.offset
22

    
23
if [ "$1" = "autoconf" ]; then
24
        if [ -f "${MAIL_LOG}" -a -n "${LOGTAIL}" -a -x "${LOGTAIL}" ] ; then
25
		echo yes
26
	else
27
		echo no
28
	fi
29
	exit 0
30
fi
31

    
32
if [ "$1" = "config" ]; then
33
	echo 'graph_title Amavis message filtering'
34

    
35
	echo 'graph_category antivirus'
36
	echo 'graph_vlabel Mails per minute'
37
	echo 'graph_args --base 1000 -l 0'
38

    
39
	echo 'graph_order clean p_spam b_spam virus total'
40

    
41
	echo 'clean.min 0'
42
	echo 'clean.type ABSOLUTE'
43
	#echo 'clean.cdef clean,60,*'
44
	echo 'clean.draw AREA'
45

    
46
		for i in p_spam b_spam virus;
47
		do
48
			echo "$i.min 0"
49
			echo "$i.type ABSOLUTE";
50
			#echo "$i.cdef $i,60,*";
51
			echo "$i.draw STACK";
52
		done
53

    
54
	echo 'clean.label Passed CLEAN'
55
	echo 'p_spam.label Passed SPAMMY'
56
	echo 'b_spam.label Blocked SPAMMY'
57
	echo 'virus.label Blocked INFECTED'
58
	echo 'total.label Total'
59
	echo 'total.graph no'
60
	echo 'clean.colour 00ff00'
61
	echo 'p_spam.colour ff4000'
62
	echo 'b_spam.colour ff0000'
63
	echo 'virus.colour 000000'
64
        exit 0
65

    
66
fi
67

    
68

    
69

    
70

    
71
$LOGTAIL ${MAIL_LOG} $STATEFILE | \
72
awk 'BEGIN { clean_count=0; passed_spam_count=0; blocked_spam_count=0; infected_count=0; total=0 }
73

    
74
	{
75

    
76
               if (index($0, "Passed CLEAN")) { clean_count++ ; total++ }
77
               else if (index($0, "Passed SPAMMY")) { passed_spam_count++ ; total++ }
78
               else if (index($0, "Blocked SPAMMY")) { blocked_spam_count++ ; total++ }
79
               else if (index($0, "INFECTED")) { infected_count++ ; total++ }
80
	}
81
	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 }'