dspam munin plugin

Here's the code for a small munin plugin that simply queries dspam's database (mysql used here) and displays the data for use by munin.

# Plugin to monitor dspam
# arch-tag: c7008208-3a23-45ed-8837-a45c05f9f6b0


if [ "$1" = "config" ]; then

        echo 'graph_title DSpam totals'
        echo 'graph_category email'
        echo "graph_order spam_classified spam_misclassified inno_classified inno_misclassified"
        echo "graph_args --base 1000"
        echo 'graph_vlabel mails'
        echo 'spam_classified.label spam mails'
        echo 'spam_classified.type GAUGE'
        echo 'spam_misclassified.label false negatives'
        echo 'spam_misclassified.type GAUGE'
        echo 'inno_classified.label innocent mails'
        echo 'inno_classified.type GAUGE'
        echo 'inno_misclassified.label false positives'
        echo 'inno_misclassified.type GAUGE'

        exit 0

echo "SELECT SUM(spam_classified) as 'spam_classified.value',"\
           " SUM(innocent_classified) as 'inno_classified.value',"\
           " SUM(spam_misclassified) as 'spam_misclassified.value',"\
           " SUM(innocent_misclassified) as 'inno_misclassified.value'"\
           " from dspam.dspam_stats;" \
| mysql -u dspam --batch --vertical \
| sed 's/\*// ; T nondel ; D ; : nondel ; s/ //g ; s/:/ /' 2>/dev/null
# yay, sed magic rocks :)