Monitor Dovecot with Munin on OpenBSD

    

At the time of writing, Munin on OpenBSD doesn’t come with a dovecot dedicated plugin. I’m not sure it even comes with an IMAP plugin. Anyway, you can get one from the “Munin plugin repository” and run it on your BSD box.

Here’s how:

# diff -U 2 dovecot.orig dovecot
--- dovecot.orig  Sun Jul 24 11:06:17 2011
+++ dovecot     Sun Jul 24 11:28:14 2011
@@ -31,5 +31,5 @@
 # Configuration
 ######################
-STAT_FILE=/var/lib/munin/plugin-state/plugin-dovecot.state
+STAT_FILE=${statefile:-/var/lib/munin/plugin-state/plugin-dovecot.state}
 EXPR_BIN=/usr/bin/expr
 LOGFILE=${logfile:-/var/log/dovecot-info.log}
@@ -46,5 +46,5 @@
        echo 'graph_vlabel Contadores de Login'
        echo 'graph_total total'
-       echo 'graph_category Correo'
+       echo 'graph_category Dovecot'

        echo 'login_total.label Total Logins'
@@ -78,5 +78,5 @@
 ######################

-NEW_TOTAL=$(egrep '*Login' $LOGFILE | grep "`date '+%Y-%m-%d'`" | sort | wc -l)
+NEW_TOTAL=$(egrep '*Login' $LOGFILE | grep "`date '+%Y-%m-%d'`" | sort | wc -l)
 OLD_TOTAL=$(grep TOTAL $STAT_FILE | cut -f2 -d '=')
 TOTAL=$(($NEW_TOTAL - $OLD_TOTAL))
@@ -89,5 +89,5 @@
 # Connected Users
 ######################
-DISCONNECTS=$(egrep '*Disconnected' $LOGFILE | sort | wc -l)
+DISCONNECTS=$(egrep '*Disconnected' $LOGFILE | sort | wc -l)
 CONNECTS=$(egrep '.*Login' $LOGFILE | sort | wc -l)
 DISCON=$(($CONNECTS - $DISCONNECTS))
# vi /etc/munin/plugin-conf.d/openbsd-packages
(...)
[dovecot]
env.logfile /var/log/maillog
env.statefile /var/run/munin/plugin-dovecot.state
(...)

Tada!

Note that I also configured newsyslog to give permissions to munin on maillog:

# vi /etc/newsyslog.conf
(...)
/var/log/maillog        root:_munin     640  7     *    24    Z
(...)

That’s All Folks!
Happy graphing!