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:

  • Grab the dovecot1.2.6 plugin ;
  • Install it ; I dropped it in /etc/munin/plugins/ ;
  • Apply some minor modification to fit OpenBSD:
    # 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))
  • Configure Munin:
    # vi /etc/munin/plugin-conf.d/openbsd-packages
    (...)
    [dovecot]
    env.logfile /var/log/maillog
    env.statefile /var/run/munin/plugin-dovecot.state
    (...)
    
  • Restart munin-node and wait 5 minutes

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!

1 Comment

  • ptiJo Wed, 27 Jul 2011 11:01:40 +0000 Reply

    I had permission issues with plugin-dovecot.state.
    The exact errors were:

    /etc/munin/plugins/dovecot[72]: cannot create /var/run/munin/plugin-dovecot.state: Permission denied

    This was because munin runs as nobody. The file is created using the following permissions:

    -rw-rw-r-- 1 nobody _munin 69B Jul 27 10:10 /var/run/munin/plugin-dovecot.state

    Either set the permissions yourself of issue a

    # chown _munin:_munin /var/run/munin &amp
    # chmod 0664 /var/run/munin

Leave a Reply

Your email address will not be published. Required fields are marked *

*

%d bloggers like this: