From f148284aafbdb7c79495ed97b2ecfa13c38d5e7b Mon Sep 17 00:00:00 2001 From: Paul Saunders Date: Wed, 8 Dec 2010 18:51:08 +0100 Subject: [PATCH] Initial version --- plugins/other/sa-learn | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 plugins/other/sa-learn diff --git a/plugins/other/sa-learn b/plugins/other/sa-learn new file mode 100755 index 00000000..7b3a49d7 --- /dev/null +++ b/plugins/other/sa-learn @@ -0,0 +1,40 @@ +#!/bin/bash +#%# family=contrib + +case $1 in + config) + cat <<'EOM' +graph_title SA-Learn Magic +graph_vlabel Count +graph_args --base 1000 -l 0 +graph_category Mail +spam.label Num Spam +spam.type GAUGE +ham.label Num Ham +ham.type GAUGE +tokens.label Num Tokens +tokens.type GAUGE +EOM + exit 0;; +esac + +## Print values +BayesDir=${BayesDir:-/var/lib/MailScanner} + +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 +done