dovecot mailbox quota monitoring, alarming xymon

Usually with dovecot a warn script is used to inform mailbox users via mail, depending on the different levels of their mail quota. For some admins it might be helpfull to get alarmed in xymon too.

So here is a small client script /usr/lib/hobbit/client/ext/ for use on your mailserver,

MSG="Mailbox Quota Status"
sudo /usr/bin/doveadm quota get -A  > /tmp/quota.lst 2>/dev/null;
/bin/cat  /tmp/quota.lst | /usr/bin/sort -u | /bin/grep "STORAGE" | /usr/bin/sort -rnk5 > /tmp/quota-percent.lst
RESULT=`/bin/cat /tmp/quota-percent.lst | /usr/bin/awk -F" " '{ print $5 }' | /usr/bin/numgrep   /97..100/ | /usr/bin/head -1`
if [ "$RESULT" -ge 0 ]
MSG2=`/bin/cat /tmp/quota-percent.lst | /usr/bin/awk -F" " '{ print $1 " " $5 "%"}' | /usr/bin/numgrep  /85..100/`
#send the results to hobbit so it can be graphed
exit 0

You may need edit /etc/sudoers in order to allow the account hobbit to run the doveadm-command via sudo:

hobbit ALL=(root) NOPASSWD: /usr/bin/doveadm

To start it in the client edit /usr/lib/hobbit/client/etc/clientlaunch.cfg:

     ENVFILE $HOBBITCLIENTHOME/etc/hobbitclient.cfg
     LOGFILE /var/log/hobbit/mquota.log
     INTERVAL 5m

There is nothing to add at xymonserver. The new mquota should apear in the client row, once you've restarted client and server.

In my example here alarming only is done in yellow, if some mailbox reached over 97 % quota and showing all mailboxes reaching over 85 % quota level, without any graph

Robert Schetterer, 28 Feb 2013

   Xymon    Dovecot    quota