EzyMailHostingAdministration

How to monitor Zimbra services

Zimbra Email serviceMonitoring and checking Zimbra mail services is important for system administrators. If the system fails, administrators need to be among the first to know it is no longer working. This article presents a way to help administrators learn about the system’s status promptly. Configuring Zimbra service monitoring through Zabbix

  1. Create zimbra_status.sh in /opt with the following contents.

    
    #!/bin/bash
    
    INIT_ZIMBRA_PATH=/etc/init.d/zimbra
    TMP_STATUS=/tmp/tmp_zimbra_status
    RESULT_STATUS=/tmp/tmp_zimbra_result
    HOSTNAME=$1
    
    /etc/init.d/zimbra status > $TMP_STATUS
    
    if [ -e $RESULT_STATUS ]; then
       `rm -f $RESULT_STATUS`
    fi
    
    cat $TMP_STATUS | while read LINE
    do
            if [ "$(echo $LINE | grep -i antispam | grep -i Running)" ]; then
              echo "- zimbra.antispam 1" > $RESULT_STATUS
            elif [ "$(echo $LINE | grep -i antispam)" ]; then
              echo "- zimbra.antispam 0" > $RESULT_STATUS
    
            elif [ "$(echo $LINE | grep -i antivirus | grep -i Running)" ]; then
              echo "- zimbra.antivirus 1" >> $RESULT_STATUS
            elif [ "$(echo $LINE | grep -i antivirus)" ]; then
              echo "- zimbra.antivirus 0" >> $RESULT_STATUS
    
            elif [ "$(echo $LINE | grep -i ldap | grep -i Running)" ]; then
              echo "- zimbra.ldap 1"  >> $RESULT_STATUS
            elif [ "$(echo $LINE | grep -i ldap)" ]; then
              echo "- zimbra.ldap 0"  >> $RESULT_STATUS
    
            elif [ "$(echo $LINE | grep -i logger | grep -i Running)" ]; then
              echo "- zimbra.logger 1" >> $RESULT_STATUS
            elif [ "$(echo $LINE | grep -i logger)" ]; then
              echo "- zimbra.logger 0" >> $RESULT_STATUS
    
    
            elif [ "$(echo $LINE | grep -i mailbox | grep -i Running)" ]; then
              echo "- zimbra.mailbox 1" >> $RESULT_STATUS
            elif [ "$(echo $LINE | grep -i mailbox)" ]; then
              echo "- zimbra.mailbox 0" >> $RESULT_STATUS
    
            elif [ "$(echo $LINE | grep -i mta | grep -i Running)" ]; then
              echo "- zimbra.mta 1" >> $RESULT_STATUS
            elif [ "$(echo $LINE | grep -i mta)" ]; then
              echo "- zimbra.mta 0" >> $RESULT_STATUS
    
            elif [ "$(echo $LINE | grep -i snmp | grep -i Running)" ]; then
              echo "- zimbra.snmp 1" >> $RESULT_STATUS
            elif [ "$(echo $LINE | grep -i snmp)" ]; then
              echo "- zimbra.snmp 0" >> $RESULT_STATUS
    
            elif [ "$(echo $LINE | grep -i spell | grep -i Running)" ]; then
              echo "- zimbra.spell 1" >> $RESULT_STATUS
            elif [ "$(echo $LINE | grep -i spell)" ]; then
              echo "- zimbra.spell 0" >> $RESULT_STATUS
    
            elif [ "$(echo $LINE | grep -i stats | grep -i Running)" ]; then
              echo "- zimbra.stats 1" >> $RESULT_STATUS
            elif [ "$(echo $LINE | grep -i stats)" ]; then
              echo "- zimbra.stats 0" >> $RESULT_STATUS
    
            elif [ "$(echo $LINE | grep -i zmconfigd | grep -i Running)" ]; then
              echo "- zimbra.zmconfigd 1" >> $RESULT_STATUS
            elif [ "$(echo $LINE | grep -i zmconfigd)" ]; then
              echo "- zimbra.zmconfigd 0" >> $RESULT_STATUS
    
            elif [ "$(echo $LINE | grep -i zmfreshclamctl |grep not)" ]; then
              echo "- zimbra.zmfreshclamctl 0" >> $RESULT_STATUS
    #        elif [ "$(echo $LINE | grep -i zmfreshclamctl)" ]; then
    #          echo "- zimbra.zmfreshclamctl 0" >> $RESULT_STATUS
    
            elif [ "$(echo $LINE | grep -i zmapachectl |grep not)" ]; then
              echo "- zimbra.zmapachectl 0" >> $RESULT_STATUS
    
            fi
    done
    
    if [ ! $ZMFreshClam ]; then
            echo "- zimbra.zmfreshclamctl 1" >> $RESULT_STATUS
    else
            echo "- zimbra.zmfreshclamctl 0" >> $RESULT_STATUS
    fi
    
    if [ -e $RESULT_STATUS ]; then
       `zabbix_sender -i $RESULT_STATUS -c /etc/zabbix/zabbix_agentd.conf > /tmp/zabbix-sender_result`
       `rm -f $RESULT_STATUS`
    fi
  2. Create a cron job to check the service status every 5 minutes.

    */5 * * * * /opt/zimbra_status.sh &>/dev/null
  3. Download the Template file below and import it into ZABBIX. Zimbra-Service_xml

EOF.← Back to articles