plugin-spamassassin: munin-spamassassin.freebsd

File munin-spamassassin.freebsd, 1.6 kB (added by LapoLuchini, 6 years ago)

spamassassin.2 adapted to work with FreeBSD 6-STABLE & SpamAssassin 3.1.6

Line 
1 #!/bin/sh
2 #
3 # Plugin to count the SpamAssassin troughput
4 #
5 # Contributed by David Obando - 16.11.2005
6 #
7 #  2006.aug.21. - grin@grin.hu - fix autoconf, insecure tmp file
8 #               - added mail count
9 #               - save less irrelevant data into tmp
10 #               - requires in plugin-conf.d/munin-node (to access syslog):
11 #                 [spamassassin]
12 #                 group adm
13 #
14 # Magic markers - optional - used by installation scripts and
15 # munin-config:
16 #
17 #%# family=manual
18 #%# capabilities=autoconf
19 maillog=/var/log/maillog
20
21 if [ "$1" = "autoconf" ]; then
22         if [ -r $maillog ]; then
23                 echo "yes"
24         else
25                 echo "no (cannot read $maillog)"
26         fi
27         exit 0
28 fi
29
30 if [ "$1" = "config" ]; then
31
32         echo 'graph_title SpamAssassin stats'
33         echo 'graph_args --base 1000 -l 0 '
34         echo 'graph_vlabel  SpamAssassin mail/sec'
35         echo 'graph_order spam ham'
36         echo 'graph_category Mail'
37         echo 'mail.label mail'
38         echo 'mail.type DERIVE'
39         echo 'mail.min 0'
40         echo 'mail.draw LINE2'
41         echo 'ham.label ham'
42         echo 'ham.type DERIVE'
43         echo 'ham.min 0'
44         echo 'ham.draw LINE2'
45         echo 'spam.label spam'
46         echo 'spam.type DERIVE'
47         echo 'spam.min 0'
48         echo 'spam.draw AREA'
49         exit 0
50 fi
51
52 # create a secure tmp file
53 TEMP=`/usr/bin/mktemp /tmp/munin-sa-XXXXXX`
54 egrep "spamd: (processing message|identified spam|clean message)" $maillog >> $TEMP
55
56 echo -n "mail.value " && grep "processing message" $TEMP | wc -l
57 echo -n "spam.value " && grep "identified spam" $TEMP | wc -l
58 echo -n "ham.value " && grep "clean message" $TEMP | wc -l
59
60 rm $TEMP