Zimbra monitoring with zabbix

Submitted by DenRaf on Fri, 12/04/2009 - 17:37

At our company we run zimbra as our collaboration tool and we use zabbix as our monitoring solution. Almost every service we have is monitored nicely, but unfortunately our zimbra was not. Because zimbra exists out of several services you want to know the status of every service. For that I wrote a little script.

First of all the zabbix agent configuration:

UserParameter=zimbra.clamav,/etc/zabbix/check_zimbra.sh antivirus
UserParameter=zimbra.spam,/etc/zabbix/check_zimbra.sh antispam
UserParameter=zimbra.logger,/etc/zabbix/check_zimbra.sh logger
UserParameter=zimbra.mailbox,/etc/zabbix/check_zimbra.sh mailbox
UserParameter=zimbra.mta,/etc/zabbix/check_zimbra.sh mta
UserParameter=zimbra.snmp,/etc/zabbix/check_zimbra.sh snmp
UserParameter=zimbra.spell,/etc/zabbix/check_zimbra.sh spell
UserParameter=zimbra.stats,/etc/zabbix/check_zimbra.sh stats

This use the custom check_zimbra:



#check if file exists
if [[ -e $file ]]
OLD=`stat -c %Z $file`
NOW=`date +%s`

export PATH=$PATH:/opt/zimbra/bin
# if older then maxage, update file
if [[ `expr $NOW - $OLD` -gt $maxage ]]
sudo -u zimbra zmcontrol status > $file


export PATH=$PATH:/opt/zimbra/bin
sudo -u zimbra zmcontrol status > $file

AVSTATUS=`cat $file |grep $check|awk '{ print $2 }'`

if [[ $AVSTATUS != "Running" ]]; then
echo 0

echo 1

As you can see we store the output of the slow zmcontrol in a file for a configurable amount of time. This way you can cache that output and win some time.
For this to run you need to add the next rule to the /etc/sudoers file:

zabbix ALL=(zimbra) NOPASSWD:/opt/zimbra/bin/zmcontrol