Loading...
 
Skip to main content

SysAdmin Blog

graphing spamdb state with munin - v2

Alexander Bochmann Saturday 21 of November, 2009
Some small updates from yesterday:
  • added a graph for distinct hosts in greylist db
  • to that end, now writing the two values I need from spamdb output to a temp file, so I don't have to run it twice
  • changed colours for the graph lines (needs munin > 1.2.5 on the server)
  • set lowest display value to 11 to better use space available for graphing (might need to be changed if trapped entries drop very low)

#!/bin/sh
#
# Parameters:
#
#       config   (required)
#       autoconf (optional - used by munin-config)
#
# Magick markers (optional):
#%# family=auto
#%# capabilities=autoconf
#
# A. Bochmann 2009, based on standard munin plugin

if [ "$1" = "autoconf" ]; then
        if ( spamdb >/dev/null 2>&1 ); then
                echo yes
                exit 0
        else
                if [ $? -eq 127 ]; then
                        echo "no (could not run \"spamdb\")"
                        exit 1
                else
                        echo no
                        exit 1
                fi
        fi
fi

if [ "$1" = "config" ]; then
        echo 'graph_title spamdb state'
        echo 'graph_args --logarithmic --base 1000 -l 11'
        echo 'graph_vlabel spamdb state counts'
        echo 'graph_category other'
        echo 'graph_scale no'
        echo 'GREY.label greylist entries'
        echo 'GREY.type GAUGE'
        echo 'GREY.colour 000066'
        echo 'GREY_HOSTS.label greylisted hosts'
        echo 'GREY_HOSTS.type GAUGE'
        echo 'GREY_HOSTS.colour 3333CC'
        echo 'WHITE.label whitelisted hosts'
        echo 'WHITE.type GAUGE'
        echo 'WHITE.colour 00FF00'
        echo 'TRAPPED.label trapped hosts'
        echo 'TRAPPED.type GAUGE'
        echo 'TRAPPED.colour FF0000'
        exit 0
fi

TMPFILE=`mktemp -p /var/tmp spamdb.XXXXXXXXXX` || exit 1
spamdb | awk -F'|' '$1 != "SPAMTRAP" {print $1 " " $2}' > $TMPFILE
awk '{print $1}' $TMPFILE | sort | uniq -c | awk '{print $2 ".value " $1}'
awk '$1 == "GREY" {print $2}' $TMPFILE | sort | uniq | wc -l | awk '{print "GREY_HOSTS.value " $1}'
rm $TMPFILE


spamdb graph with greylist host count