plugin-spamassassin: amavis

File amavis, 1.8 kB (added by anarcat, 6 years ago)

security fix and other improvements for amavis detection

Line 
1 #!/bin/sh
2 #
3 # Plugin to count the SpamAssassin troughput
4 #
5 # Contributed by David Obando - 16.11.2005
6 # edited by Cornelius Bolten - 11.07.2006
7 # edited by Anarcat - 14.08.2006
8 #
9 # Magic markers - optional - used by installation scripts and
10 # munin-config:
11 #
12 #%# family=contrib
13 #%# capabilities=autoconf
14
15 if [ "$1" = "autoconf" ]; then
16         echo yes
17         exit 0
18 fi
19
20 if [ "$1" = "config" ]; then
21
22         echo 'graph_title Spam detection'
23         echo 'graph_args --base 1000 -l 0 '
24         echo 'graph_vlabel emails / ${graph_period}'
25         echo 'graph_order spam ham'
26         echo 'graph_category Mail'
27         echo 'ham.label ham'
28         echo 'ham.type DERIVE'
29         echo 'ham.min 0'
30         echo 'spam.label spam'
31         echo 'spam.type DERIVE'
32         echo 'spam.min 0'
33         exit 0
34 fi
35
36 TMP=`mktemp /tmp/tmp.XXXXXXXX`
37
38 # relevant samples:
39 # Aug 14 09:03:35 hostname amavis[7216]: (07216-08) Passed, <foo@example.com> -> <bar@example.com>, Message-ID: <4u8532u58945hi532h>, Hits: 2.253
40 # Aug 14 09:03:35 hostname amavis[7216]: (07216-08) Passed, <foo@example.com> -> <bar@example.com>, Message-ID: <4u8532u58945hi532h>, Hits: -1.300
41 # Aug 14 09:03:35 hostname amavis[7216]: (07216-08) Passed, <foo@example.com> -> <bar@example.com>, Message-ID: <4u8532u58945hi532h>, Hits: 0
42 # Aug 14 09:03:35 hostname amavis[7216]: (07216-08) Passed, <foo@example.com> -> <bar@example.com>, Message-ID: <4u8532u58945hi532h>, Hits: -
43
44 # detect hits > 5
45 SPAM="Hits: \([5-9]\(\.\|\$\)\|[1-9][0-9][0-9]*\(\.\|\$\)\)"
46 # hits < 5, including negatives
47 HAM="Hits: \([0-4]\(\.\|\$\)\|-\)"
48
49 grep "amavis.*Hits" /var/log/syslog >> $TMP
50
51 # debug: number of hits
52 #echo -n "hits " && wc -l < $TMP
53 echo -n "spam.value " && grep "$SPAM" $TMP | wc -l
54 echo -n "ham.value " && grep "$HAM" $TMP | wc -l
55
56 # debug: find which statement don't match anything
57 #grep -v "$HAM" < $TMP | grep -v "$SPAM"
58 rm -f $TMP