Projet

Général

Profil

Révision 8b30228c

ID8b30228c7d402583fa78d995772772663f8deb02
Parent 9fb241c4
Enfant 57f012bd

Ajouté par Thomas Mangin/Nick Lock/William Towle il y a presque 14 ans

Initial version

Voir les différences:

plugins/other/amavis_awk
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=/var/lib/munin/plugin-state/amavis.offset
22

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

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

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

  
40
	echo 'graph_order clean p_spam b_spam virus total'
41
	
42
	echo 'clean.min 0'
43
	echo 'clean.type ABSOLUTE'
44
	#echo 'clean.cdef clean,60,*'
45
	echo 'clean.draw AREA'
46

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

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

  
67
fi
68

  
69

  
70

  
71

  
72
$LOGTAIL ${MAIL_LOG} $STATEFILE | \
73
awk 'BEGIN { na= 0; nb= 0; nc= 0; nd= 0; total= 0 } 
74

  
75
	{       
76
	
77
               if (index($0, "Passed CLEAN")) { na++ ; total++ } 
78
               else if (index($0, "Passed SPAMMY")) { nb++ ; total++ }    
79
               else if (index($0, "Blocked SPAMMY")) { nc++ ; total++ }
80
               else if (index($0, "INFECTED")) { nd++ ; total++ }
81
	}
82
	END { print "clean.value " na"\np_spam.value " nb"\nb_spam.value " nc"\nvirus.value " nd"\ntotal.value " total }'
83

  
84

  

Formats disponibles : Unified diff