From 10b89a6d67d52f0fedbc8b62be75afd90eb94dcb Mon Sep 17 00:00:00 2001 From: Paul Saunders Date: Thu, 12 Jan 2012 12:42:47 +0000 Subject: [PATCH] sa-learn: Add documentation Add POD documentation and tidy up --- plugins/other/sa-learn | 71 +++++++++++++++++++++++++++++++----------- 1 file changed, 53 insertions(+), 18 deletions(-) diff --git a/plugins/other/sa-learn b/plugins/other/sa-learn index 7b3a49d7..547737dd 100755 --- a/plugins/other/sa-learn +++ b/plugins/other/sa-learn @@ -1,9 +1,44 @@ #!/bin/bash + +: <<=cut +=head1 NAME + +sa-learn - Munin plugin to monitor spamassasin bayes database size + +=head1 APPLICABLE SYSTEMS + +Any server running spamassassin + +=head1 CONFIGURATION + +This plugin assumes your Spamassassin database is in /var/lib/MailScanner. +If it's elsewhere (or you want to use a different database) you will need +a configuration such as: + + [sa-learn] + env.BayesDir /path/to/bayes/directory/ + user mail + +(where 'user mail' refers to a user that can read the database). + +=head1 MAGIC MARKERS + #%# family=contrib +=head1 VERSION + +2 + +=head1 AUTHOR + +Paul Saunders L + +=cut +#' + case $1 in - config) - cat <<'EOM' + config) + cat <<'EOM' graph_title SA-Learn Magic graph_vlabel Count graph_args --base 1000 -l 0 @@ -15,26 +50,26 @@ ham.type GAUGE tokens.label Num Tokens tokens.type GAUGE EOM - exit 0;; + exit 0;; esac ## Print values BayesDir=${BayesDir:-/var/lib/MailScanner} -sa-learn --dbpath $BayesDir --dump magic 2>/dev/null | while read line +sa-learn --dbpath $BayesDir/ --dump magic 2>/dev/null | while read line do - case "$line" in - *nspam*) - echo -n "spam.value " - echo $line | awk '{print $3}' - ;; - *nham*) - echo -n "ham.value " - echo $line | awk '{print $3}' - ;; - *ntokens*) - echo -n "tokens.value " - echo $line | awk '{print $3}' - ;; - esac + case "$line" in + *nspam*) + echo -n "spam.value " + echo $line | awk '{print $3}' + ;; + *nham*) + echo -n "ham.value " + echo $line | awk '{print $3}' + ;; + *ntokens*) + echo -n "tokens.value " + echo $line | awk '{print $3}' + ;; + esac done