EzyMailHostingAdministration

How to monitor Zimbra services

Zimbra Email serviceการ monitor และตรวจสอบการทำงานของ Zimbra mail เป็นสิ่งสำคัญสำหรับ System admin ดังนั้นหากการทำงานของระบบเกิดล้มเหลวขึ้นมา ผู้ดูแลจำเป็นจะต้องรู้ถึงการที่ระบบไม่สามารถทำงานได้ในลำดับต้นๆ ในบทความนี้จะนำเสนอวิธีการที่จะช่วยให้ผู้ดูแลระบบสามารถล่วงรู้การทำงานของระบบได้อย่างทันท่วงที วิธีการ config ระบบ monitor Zimbra services ผ่าน Zabbix

  1. สร้างไฟล์ zimbra_status.sh บน /opt โดยให้มีข้อมูลตามด้านล่าง

    
    #!/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. สร้าง cron เพื่อทำการตรวจสอบสถานะการทำงานทุกๆ 5 นาที

    */5 * * * * /opt/zimbra_status.sh &>/dev/null
  3. Download Template file ด้านล่างเพื่อนำไป import เข้าสู่ ZABBIX Zimbra-Service_xml

EOF.← กลับไปอ่านบทความอื่น