Projet

Général

Profil

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

root / plugins / mail / sa-learn @ e5ce7492

Historique | Voir | Annoter | Télécharger (1,32 ko)

1
#!/bin/bash
2

    
3
: <<=cut
4
=head1 NAME
5

    
6
sa-learn - Munin plugin to monitor spamassasin bayes database size
7

    
8
=head1 APPLICABLE SYSTEMS
9

    
10
Any server running spamassassin
11

    
12
=head1 CONFIGURATION
13

    
14
This plugin assumes your Spamassassin database is in /var/lib/MailScanner.
15
If it's elsewhere (or you want to use a different database) you will need
16
a configuration such as:
17

    
18
   [sa-learn]
19
      env.BayesDir /path/to/bayes/directory/
20
      user mail
21

    
22
(where 'user mail' refers to a user that can read the database).
23

    
24
=head1 MAGIC MARKERS
25

    
26
#%# family=contrib
27

    
28
=head1 VERSION
29

    
30
2
31

    
32
=head1 AUTHOR
33

    
34
Paul Saunders L<darac+munin@darac.org.uk>
35

    
36
=cut
37
#'
38

    
39
case $1 in
40
	config)
41
		cat <<'EOM'
42
graph_title SA-Learn Magic
43
graph_vlabel Count
44
graph_args --base 1000 -l 0
45
graph_category Mail
46
spam.label Num Spam
47
spam.type GAUGE
48
ham.label Num Ham
49
ham.type GAUGE
50
tokens.label Num Tokens
51
tokens.type GAUGE
52
EOM
53
		exit 0;;
54
esac
55

    
56
## Print values
57
BayesDir=${BayesDir:-/var/lib/MailScanner}
58

    
59
sa-learn --dbpath $BayesDir/ --dump magic 2>/dev/null | while read line
60
do
61
	case "$line" in
62
		*nspam*)
63
			echo -n "spam.value "
64
			echo $line | awk '{print $3}'
65
			;;
66
		*nham*)
67
			echo -n "ham.value "
68
			echo $line | awk '{print $3}'
69
			;;
70
		*ntokens*)
71
			echo -n "tokens.value "
72
			echo $line | awk '{print $3}'
73
			;;
74
	esac
75
done