Zimbra monitoring with zabbix
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:
#!/bin/bash
check=$1
maxage=30
file='/tmp/zimbra_status'
#check if file exists
if [[ -e $file ]]
then
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 ]]
then
sudo -u zimbra zmcontrol status > $file
fi
else
export PATH=$PATH:/opt/zimbra/bin
sudo -u zimbra zmcontrol status > $file
fi
AVSTATUS=`cat $file |grep $check|awk '{ print $2 }'`
if [[ $AVSTATUS != "Running" ]]; then
echo 0
fi
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



1 response to "Zimbra monitoring with zabbix"
1. A little optim..
I forgot to mention this to you earlier, but you can greatly reduce the config, if you just use 1 UserParameter like this:
UserParameter=zimbra[*],/etc/zabbix/check_zimbra.sh $1
Then you can just create items like zimbra[antivirus] instead of zimbra.antivirus and you don't need to change the zabbix_agentd.conf file if you add new checks :)
Greets,
Bart