Мониторим Exim4 через Zabbix

На нашем сервере стоит Vesta CP и в панели администратора есть графики загрузки почтовой очереди. Для автоматизации этого дела настроим Заббикс

Имеем:

  • настроенный и рабочий exim
  • настроенный и рабочий zabbix 2.2

1) Создаем в папке /usr/lib/zabbix/externalscripts файл с именем zexim4.sh и следующим содержимым. В скрипте правим переменные main_log, tmp_log, stats, указывая свои пути:

#!/bin/bash

# Egor Minko. Synchron LLC. May.2012
#
# /etc/zabbix/zabbix_agentd.conf
# Timeout=10 # If You have a lot of emails through your system - you must increase Zabbix Timeout:
# UserParameter=exim4[*],sudo /opt/zexim4 \$1
#
# Yiu will need sudo to use these commands
# /etc/sudoers
# zabbix ALL=NOPASSWD: /opt/zexim4
#

zexim4ver="ver 2.1"
rval=0

# MULTIPLE PARSERS PROTECTION
LOCK=/tmp/zexim4.pid
while [ -e "$LOCK" ]; do
PID="`cat $LOCK`"
while [ "`ps h -p $PID -o pid,comm|wc -l`" -gt 0 ]
do
sleep 0.$[ ( $RANDOM % 10 ) + 1 ]s
done
done
echo $ > $LOCK
trap "rm -f $LOCK; exit" INT TERM EXIT


# USAGE
function usage()
{
echo "zexim version: $zexim4ver"
echo "usage:"
echo " $0 deliver -- Delivered Messages"
echo " $0 arrive -- Submited Pakets"
echo " $0 error -- Errors Total for Messages"
echo " $0 defer -- Error status: Defered Messages"
echo " $0 unroute -- Error status: Unroutable address"
echo " $0 local -- Local/Virtual delivery of Messages"
echo " $0 complete -- Finished Packets"
echo " $0 reject -- Rejects Total for Packets"
echo " $0 badrelay -- Reject status: Relay not permited"
echo " $0 Pqueue -- Queue size in Packets"
echo " $0 Mqueue -- Queue size in Messages"
echo " $0 frozen -- Frozen Packets"
echo ""
echo " Packet = letter with many recipients"
echo " Message = A single message for one recipient"
echo ""
}

# GLOBAL INSTRUCTIONS
CACHETTL="58" # sec
main_log=/var/log/exim4/mainlog
tmp_log=/tmp/exim_log_pars.txt
stats=/tmp/stats.txt
exim=`which exim`


function create_data()
{
# CREATING STATS FILE
if [ ! -e "$stats" ] ; then touch $stats ; fi

# CREATING TMP FILE
# additional 'sub' in 'awk' used for cutting special chars that breaks next 'sed' parsing. For now: []()
position=`tail -1 $stats |awk '{print $1" "$2" "$3}'`
position_log=`tail -1 $main_log | awk '{sub(/\]/,""); sub(/\[/,""); sub(/\)/,""); sub(/\(/,""); print $1" "$2" "$3}'`

# BUILDING REPORT ONLY IF THERE IS DIFFERENCE BETWEEN LAST LINE IN LOG
if [ "$position" == "$position_log" ]
then
vars="0 0 0 0 0 0 0 0 0"
else
if ! grep -qc "" $stats || ! awk '{sub(/\]/,""); sub(/\[/,""); sub(/\)/,""); sub(/\(/,""); print}' $main_log|grep -qc "$position"
then
awk '{sub(/\]/,""); sub(/\[/,""); sub(/\)/,""); sub(/\(/,""); print}' $main_log $main_log > $tmp_log
else
awk '{sub(/\]/,""); sub(/\[/,""); sub(/\)/,""); sub(/\(/,""); print}' $main_log |sed 1,/"$position"/d | sed /"$position"/d > $tmp_log
fi
vars="`awk '\
BEGIN {deliver=0; arrive=0; error=0; local=0; complete=0; reject=0; badrelay=0; defer=0; unroute=0}\
/[-=]>/ { deliver++ }\
/<=/ {arrive++}\
/ \*\* / {error++}\
/[=][=]/ {defer++}\
/al_delivery/ {local++}\
/Completed/ {complete++}\
/rejected/ {reject++}\
/relay not permitted/ {badrelay++}\
/Unrouteable address/ {unroute++}\
END {print deliver" "arrive" "error" "defer" "local" "complete" "reject" "badrelay" "unroute}' $tmp_log`"
fi

queue_size="`$exim -bpc`"
recipients="`exipick -bpu |awk '$2==""{print $1}'|grep -vE "^$"|wc -l`"
frozen="`exiqgrep -zi|wc -l`"
echo $position_log $vars $queue_size $recipients $frozen &gt;&gt; $stats

}

function zabbix_answer()
{
case $CASE_VALUE in
'deliver')
tail -n1 "$stats"|awk '{print $4}'
rval=$?;;
'arrive')
tail -n1 "$stats"|awk '{print $5}'
rval=$?;;
'error')
tail -n1 "$stats"|awk '{print $6}'
rval=$?;;
'defer')
tail -n1 "$stats"|awk '{print $7}'
rval=$?;;
'local')
tail -n1 "$stats"|awk '{print $8}'
rval=$?;;
'complete')
tail -n1 "$stats"|awk '{print $9}'
rval=$?;;
'reject')
tail -n1 "$stats"|awk '{print $10}'
rval=$?;;
'badrelay')
tail -n1 "$stats"|awk '{print $11}'
rval=$?;;
'unroute')
tail -n1 "$stats"|awk '{print $12}'
rval=$?;;
'Pqueue')
tail -n1 "$stats"|awk '{print $13}'
rval=$?;;
'Mqueue')
tail -n1 "$stats"|awk '{print $14}'
rval=$?;;
'frozen')
tail -n1 "$stats"|awk '{print $15}'
rval=$?;;
'version')
echo "$zexim4ver"
rm $LOCK
trap - INT TERM EXIT
exit $rval;;
*)
usage
rm $LOCK
trap - INT TERM EXIT
exit $rval;;
esac
}

if [ -s "$stats" ]; then
TIMECACHE=`stat -c"%Z" "$stats"`
else
TIMECACHE=0
fi


TIMENOW=`date '+%s'`
if [[ $# == 1 ]];then
CASE_VALUE=$1
if [ "$(($TIMENOW - $TIMECACHE))" -gt "$CACHETTL" ]; then
create_data
fi
zabbix_answer
if [ "$rval" -ne 0 ]; then
echo "ZBX_NOTSUPPORTED"
fi
rm $LOCK
trap - INT TERM EXIT
exit $rval
else
usage
rm $LOCK
trap - INT TERM EXIT
exit 0
fi

Проверяем, как работает наш скрипт:

sudo -u zabbix /usr/lib/zabbix/externalscripts/zexim4.sh Pqueue

2) Правим файл /etc/zabbix/zabbix_agentd.conf, в конец вставляем:

Timeout=10
UserParameter=exim4[*],sudo /usr/lib/zabbix/externalscripts/zexim4.sh \$1

Перезапускаем заббикс-агент:

sudo service zabbix-agent restart

3) Правим файл /etc/sudoers, добавляем в него строчку

zabbix ALL=(ALL) NOPASSWD: ALL

4) Создаем шаблон для Zabbix-а

Создаем файл Exim4-stats.xml со следющим содержимым и импортируем его в Заббикс как шаблон.

<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export version="1.0" date="25.05.12" time="14.02">
<hosts>
<host name="Exim4-stats">
<proxy_hostid>0</proxy_hostid>
<useip>1</useip>
<dns></dns>
<ip>127.0.0.1</ip>
<port>10050</port>
<status>3</status>
<useipmi>0</useipmi>
<ipmi_ip>127.0.0.1</ipmi_ip>
<ipmi_port>623</ipmi_port>
<ipmi_authtype>0</ipmi_authtype>
<ipmi_privilege>2</ipmi_privilege>
<ipmi_username></ipmi_username>
<ipmi_password></ipmi_password>
<groups>
<group>Synchron Templates</group>
</groups>
<triggers/>
<items>
<item type="0" key="exim4[arrive]" value_type="3">
<description>Exim4/Submit Letters</description>
<ipmi_sensor></ipmi_sensor>
<delay>60</delay>
<history>90</history>
<trends>365</trends>
<status>0</status>
<data_type>0</data_type>
<units>letters/mi</units>
<multiplier>0</multiplier>
<delta>0</delta>
<formula>1</formula>
<lastlogsize>0</lastlogsize>
<logtimefmt></logtimefmt>
<delay_flex></delay_flex>
<authtype>0</authtype>
<username></username>
<password></password>
<publickey></publickey>
<privatekey></privatekey>
<params></params>
<trapper_hosts></trapper_hosts>
<snmp_community>public</snmp_community>
<snmp_oid>interfaces.ifTable.ifEntry.ifInOctets.1</snmp_oid>
<snmp_port>161</snmp_port>
<snmpv3_securityname></snmpv3_securityname>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authpassphrase></snmpv3_authpassphrase>
<snmpv3_privpassphrase></snmpv3_privpassphrase>
<applications>
<application>ZEXIM</application>
</applications>
</item>
<item type="0" key="exim4[badrelay]" value_type="3">
<description>Exim4/Relay not permited</description>
<ipmi_sensor></ipmi_sensor>
<delay>60</delay>
<history>90</history>
<trends>365</trends>
<status>0</status>
<data_type>0</data_type>
<units>err/min</units>
<multiplier>0</multiplier>
<delta>0</delta>
<formula>1</formula>
<lastlogsize>0</lastlogsize>
<logtimefmt></logtimefmt>
<delay_flex></delay_flex>
<authtype>0</authtype>
<username></username>
<password></password>
<publickey></publickey>
<privatekey></privatekey>
<params></params>
<trapper_hosts></trapper_hosts>
<snmp_community>public</snmp_community>
<snmp_oid>interfaces.ifTable.ifEntry.ifInOctets.1</snmp_oid>
<snmp_port>161</snmp_port>
<snmpv3_securityname></snmpv3_securityname>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authpassphrase></snmpv3_authpassphrase>
<snmpv3_privpassphrase></snmpv3_privpassphrase>
<applications>
<application>ZEXIM</application>
</applications>
</item>
<item type="0" key="exim4[complete]" value_type="3">
<description>Exim4/Complete Letters</description>
<ipmi_sensor></ipmi_sensor>
<delay>60</delay>
<history>90</history>
<trends>365</trends>
<status>0</status>
<data_type>0</data_type>
<units>letters/mi</units>
<multiplier>0</multiplier>
<delta>0</delta>
<formula>1</formula>
<lastlogsize>0</lastlogsize>
<logtimefmt></logtimefmt>
<delay_flex></delay_flex>
<authtype>0</authtype>
<username></username>
<password></password>
<publickey></publickey>
<privatekey></privatekey>
<params></params>
<trapper_hosts></trapper_hosts>
<snmp_community>public</snmp_community>
<snmp_oid>interfaces.ifTable.ifEntry.ifInOctets.1</snmp_oid>
<snmp_port>161</snmp_port>
<snmpv3_securityname></snmpv3_securityname>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authpassphrase></snmpv3_authpassphrase>
<snmpv3_privpassphrase></snmpv3_privpassphrase>
<applications>
<application>ZEXIM</application>
</applications>
</item>
<item type="0" key="exim4[defer]" value_type="3">
<description>Exim4/Defered messages</description>
<ipmi_sensor></ipmi_sensor>
<delay>60</delay>
<history>90</history>
<trends>365</trends>
<status>0</status>
<data_type>0</data_type>
<units>msg/min</units>
<multiplier>0</multiplier>
<delta>0</delta>
<formula>1</formula>
<lastlogsize>0</lastlogsize>
<logtimefmt></logtimefmt>
<delay_flex></delay_flex>
<authtype>0</authtype>
<username></username>
<password></password>
<publickey></publickey>
<privatekey></privatekey>
<params></params>
<trapper_hosts></trapper_hosts>
<snmp_community>public</snmp_community>
<snmp_oid>interfaces.ifTable.ifEntry.ifInOctets.1</snmp_oid>
<snmp_port>161</snmp_port>
<snmpv3_securityname></snmpv3_securityname>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authpassphrase></snmpv3_authpassphrase>
<snmpv3_privpassphrase></snmpv3_privpassphrase>
<applications>
<application>ZEXIM</application>
</applications>
</item>
<item type="0" key="exim4[deliver]" value_type="3">
<description>Exim4/Delivered messageges</description>
<ipmi_sensor></ipmi_sensor>
<delay>60</delay>
<history>90</history>
<trends>365</trends>
<status>0</status>
<data_type>0</data_type>
<units>msg/min</units>
<multiplier>0</multiplier>
<delta>0</delta>
<formula>1</formula>
<lastlogsize>0</lastlogsize>
<logtimefmt></logtimefmt>
<delay_flex></delay_flex>
<authtype>0</authtype>
<username></username>
<password></password>
<publickey></publickey>
<privatekey></privatekey>
<params></params>
<trapper_hosts></trapper_hosts>
<snmp_community>public</snmp_community>
<snmp_oid>interfaces.ifTable.ifEntry.ifInOctets.1</snmp_oid>
<snmp_port>161</snmp_port>
<snmpv3_securityname></snmpv3_securityname>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authpassphrase></snmpv3_authpassphrase>
<snmpv3_privpassphrase></snmpv3_privpassphrase>
<applications>
<application>ZEXIM</application>
</applications>
</item>
<item type="0" key="exim4[error]" value_type="3">
<description>Exim4/Errors total</description>
<ipmi_sensor></ipmi_sensor>
<delay>60</delay>
<history>90</history>
<trends>365</trends>
<status>0</status>
<data_type>0</data_type>
<units>err/min</units>
<multiplier>0</multiplier>
<delta>0</delta>
<formula>1</formula>
<lastlogsize>0</lastlogsize>
<logtimefmt></logtimefmt>
<delay_flex></delay_flex>
<authtype>0</authtype>
<username></username>
<password></password>
<publickey></publickey>
<privatekey></privatekey>
<params></params>
<trapper_hosts></trapper_hosts>
<snmp_community>public</snmp_community>
<snmp_oid>interfaces.ifTable.ifEntry.ifInOctets.1</snmp_oid>
<snmp_port>161</snmp_port>
<snmpv3_securityname></snmpv3_securityname>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authpassphrase></snmpv3_authpassphrase>
<snmpv3_privpassphrase></snmpv3_privpassphrase>
<applications>
<application>ZEXIM</application>
</applications>
</item>
<item type="0" key="exim4[frozen]" value_type="3">
<description>Exim4/Frozen Letters</description>
<ipmi_sensor></ipmi_sensor>
<delay>60</delay>
<history>90</history>
<trends>365</trends>
<status>0</status>
<data_type>0</data_type>
<units>letters</units>
<multiplier>0</multiplier>
<delta>0</delta>
<formula>1</formula>
<lastlogsize>0</lastlogsize>
<logtimefmt></logtimefmt>
<delay_flex></delay_flex>
<authtype>0</authtype>
<username></username>
<password></password>
<publickey></publickey>
<privatekey></privatekey>
<params></params>
<trapper_hosts></trapper_hosts>
<snmp_community>public</snmp_community>
<snmp_oid>interfaces.ifTable.ifEntry.ifInOctets.1</snmp_oid>
<snmp_port>161</snmp_port>
<snmpv3_securityname></snmpv3_securityname>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authpassphrase></snmpv3_authpassphrase>
<snmpv3_privpassphrase></snmpv3_privpassphrase>
<applications>
<application>ZEXIM</application>
</applications>
</item>
<item type="0" key="exim4[local]" value_type="3">
<description>Exim4/Local Delivery</description>
<ipmi_sensor></ipmi_sensor>
<delay>60</delay>
<history>90</history>
<trends>365</trends>
<status>0</status>
<data_type>0</data_type>
<units>msg/min</units>
<multiplier>0</multiplier>
<delta>0</delta>
<formula>1</formula>
<lastlogsize>0</lastlogsize>
<logtimefmt></logtimefmt>
<delay_flex></delay_flex>
<authtype>0</authtype>
<username></username>
<password></password>
<publickey></publickey>
<privatekey></privatekey>
<params></params>
<trapper_hosts></trapper_hosts>
<snmp_community>public</snmp_community>
<snmp_oid>interfaces.ifTable.ifEntry.ifInOctets.1</snmp_oid>
<snmp_port>161</snmp_port>
<snmpv3_securityname></snmpv3_securityname>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authpassphrase></snmpv3_authpassphrase>
<snmpv3_privpassphrase></snmpv3_privpassphrase>
<applications>
<application>ZEXIM</application>
</applications>
</item>
<item type="0" key="exim4[Mqueue]" value_type="3">
<description>Exim4/Recipients in Queue</description>
<ipmi_sensor></ipmi_sensor>
<delay>60</delay>
<history>90</history>
<trends>365</trends>
<status>0</status>
<data_type>0</data_type>
<units>letters</units>
<multiplier>0</multiplier>
<delta>0</delta>
<formula>1</formula>
<lastlogsize>0</lastlogsize>
<logtimefmt></logtimefmt>
<delay_flex></delay_flex>
<authtype>0</authtype>
<username></username>
<password></password>
<publickey></publickey>
<privatekey></privatekey>
<params></params>
<trapper_hosts></trapper_hosts>
<snmp_community>public</snmp_community>
<snmp_oid>interfaces.ifTable.ifEntry.ifInOctets.1</snmp_oid>
<snmp_port>161</snmp_port>
<snmpv3_securityname></snmpv3_securityname>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authpassphrase></snmpv3_authpassphrase>
<snmpv3_privpassphrase></snmpv3_privpassphrase>
<applications>
<application>ZEXIM</application>
</applications>
</item>
<item type="0" key="exim4[Pqueue]" value_type="3">
<description>Exim4/Letters in Queue</description>
<ipmi_sensor></ipmi_sensor>
<delay>60</delay>
<history>90</history>
<trends>365</trends>
<status>0</status>
<data_type>0</data_type>
<units>letters</units>
<multiplier>0</multiplier>
<delta>0</delta>
<formula>1</formula>
<lastlogsize>0</lastlogsize>
<logtimefmt></logtimefmt>
<delay_flex></delay_flex>
<authtype>0</authtype>
<username></username>
<password></password>
<publickey></publickey>
<privatekey></privatekey>
<params></params>
<trapper_hosts></trapper_hosts>
<snmp_community>public</snmp_community>
<snmp_oid>interfaces.ifTable.ifEntry.ifInOctets.1</snmp_oid>
<snmp_port>161</snmp_port>
<snmpv3_securityname></snmpv3_securityname>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authpassphrase></snmpv3_authpassphrase>
<snmpv3_privpassphrase></snmpv3_privpassphrase>
<applications>
<application>ZEXIM</application>
</applications>
</item>
<item type="0" key="exim4[reject]" value_type="3">
<description>Exim4/Rejects total</description>
<ipmi_sensor></ipmi_sensor>
<delay>60</delay>
<history>90</history>
<trends>365</trends>
<status>0</status>
<data_type>0</data_type>
<units>err/min</units>
<multiplier>0</multiplier>
<delta>0</delta>
<formula>1</formula>
<lastlogsize>0</lastlogsize>
<logtimefmt></logtimefmt>
<delay_flex></delay_flex>
<authtype>0</authtype>
<username></username>
<password></password>
<publickey></publickey>
<privatekey></privatekey>
<params></params>
<trapper_hosts></trapper_hosts>
<snmp_community>public</snmp_community>
<snmp_oid>interfaces.ifTable.ifEntry.ifInOctets.1</snmp_oid>
<snmp_port>161</snmp_port>
<snmpv3_securityname></snmpv3_securityname>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authpassphrase></snmpv3_authpassphrase>
<snmpv3_privpassphrase></snmpv3_privpassphrase>
<applications>
<application>ZEXIM</application>
</applications>
</item>
<item type="0" key="exim4[unroute]" value_type="3">
<description>Exim4/Unroutable messages</description>
<ipmi_sensor></ipmi_sensor>
<delay>60</delay>
<history>90</history>
<trends>365</trends>
<status>0</status>
<data_type>0</data_type>
<units>err/min</units>
<multiplier>0</multiplier>
<delta>0</delta>
<formula>1</formula>
<lastlogsize>0</lastlogsize>
<logtimefmt></logtimefmt>
<delay_flex></delay_flex>
<authtype>0</authtype>
<username></username>
<password></password>
<publickey></publickey>
<privatekey></privatekey>
<params></params>
<trapper_hosts></trapper_hosts>
<snmp_community>public</snmp_community>
<snmp_oid>interfaces.ifTable.ifEntry.ifInOctets.1</snmp_oid>
<snmp_port>161</snmp_port>
<snmpv3_securityname></snmpv3_securityname>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authpassphrase></snmpv3_authpassphrase>
<snmpv3_privpassphrase></snmpv3_privpassphrase>
<applications>
<application>ZEXIM</application>
</applications>
</item>
</items>
<templates/>
<graphs>
<graph name="Exim4 Errors" width="900" height="200">
<ymin_type>0</ymin_type>
<ymax_type>0</ymax_type>
<ymin_item_key></ymin_item_key>
<ymax_item_key></ymax_item_key>
<show_work_period>0</show_work_period>
<show_triggers>0</show_triggers>
<graphtype>1</graphtype>
<yaxismin>0.0000</yaxismin>
<yaxismax>100.0000</yaxismax>
<show_legend>0</show_legend>
<show_3d>0</show_3d>
<percent_left>0.0000</percent_left>
<percent_right>0.0000</percent_right>
<graph_elements>
<graph_element item="Exim4-stats:exim4[error]">
<drawtype>1</drawtype>
<sortorder>0</sortorder>
<color>009900</color>
<yaxisside>0</yaxisside>
<calc_fnc>2</calc_fnc>
<type>0</type>
<periods_cnt>5</periods_cnt>
</graph_element>
<graph_element item="Exim4-stats:exim4[defer]">
<drawtype>1</drawtype>
<sortorder>1</sortorder>
<color>CCCC00</color>
<yaxisside>0</yaxisside>
<calc_fnc>2</calc_fnc>
<type>0</type>
<periods_cnt>5</periods_cnt>
</graph_element>
<graph_element item="Exim4-stats:exim4[badrelay]">
<drawtype>1</drawtype>
<sortorder>2</sortorder>
<color>0000AA</color>
<yaxisside>0</yaxisside>
<calc_fnc>2</calc_fnc>
<type>0</type>
<periods_cnt>5</periods_cnt>
</graph_element>
<graph_element item="Exim4-stats:exim4[reject]">
<drawtype>1</drawtype>
<sortorder>3</sortorder>
<color>DD00DD</color>
<yaxisside>0</yaxisside>
<calc_fnc>2</calc_fnc>
<type>0</type>
<periods_cnt>5</periods_cnt>
</graph_element>
<graph_element item="Exim4-stats:exim4[unroute]">
<drawtype>1</drawtype>
<sortorder>4</sortorder>
<color>000000</color>
<yaxisside>0</yaxisside>
<calc_fnc>2</calc_fnc>
<type>0</type>
<periods_cnt>5</periods_cnt>
</graph_element>
</graph_elements>
</graph>
<graph name="Exim4 Delivery" width="900" height="200">
<ymin_type>1</ymin_type>
<ymax_type>0</ymax_type>
<ymin_item_key></ymin_item_key>
<ymax_item_key></ymax_item_key>
<show_work_period>1</show_work_period>
<show_triggers>0</show_triggers>
<graphtype>0</graphtype>
<yaxismin>0.0000</yaxismin>
<yaxismax>100.0000</yaxismax>
<show_legend>0</show_legend>
<show_3d>0</show_3d>
<percent_left>0.0000</percent_left>
<percent_right>0.0000</percent_right>
<graph_elements>
<graph_element item="Exim4-stats:exim4[complete]">
<drawtype>0</drawtype>
<sortorder>0</sortorder>
<color>EE0000</color>
<yaxisside>0</yaxisside>
<calc_fnc>2</calc_fnc>
<type>0</type>
<periods_cnt>5</periods_cnt>
</graph_element>
<graph_element item="Exim4-stats:exim4[local]">
<drawtype>1</drawtype>
<sortorder>1</sortorder>
<color>999900</color>
<yaxisside>0</yaxisside>
<calc_fnc>2</calc_fnc>
<type>0</type>
<periods_cnt>5</periods_cnt>
</graph_element>
<graph_element item="Exim4-stats:exim4[deliver]">
<drawtype>2</drawtype>
<sortorder>3</sortorder>
<color>0000DD</color>
<yaxisside>0</yaxisside>
<calc_fnc>2</calc_fnc>
<type>0</type>
<periods_cnt>5</periods_cnt>
</graph_element>
</graph_elements>
</graph>
<graph name="Exim4 Queue" width="900" height="200">
<ymin_type>1</ymin_type>
<ymax_type>0</ymax_type>
<ymin_item_key></ymin_item_key>
<ymax_item_key></ymax_item_key>
<show_work_period>1</show_work_period>
<show_triggers>0</show_triggers>
<graphtype>0</graphtype>
<yaxismin>0.0000</yaxismin>
<yaxismax>100.0000</yaxismax>
<show_legend>0</show_legend>
<show_3d>0</show_3d>
<percent_left>0.0000</percent_left>
<percent_right>0.0000</percent_right>
<graph_elements>
<graph_element item="Exim4-stats:exim4[Pqueue]">
<drawtype>2</drawtype>
<sortorder>0</sortorder>
<color>009900</color>
<yaxisside>0</yaxisside>
<calc_fnc>2</calc_fnc>
<type>0</type>
<periods_cnt>5</periods_cnt>
</graph_element>
<graph_element item="Exim4-stats:exim4[Mqueue]">
<drawtype>0</drawtype>
<sortorder>1</sortorder>
<color>0000EE</color>
<yaxisside>0</yaxisside>
<calc_fnc>2</calc_fnc>
<type>0</type>
<periods_cnt>5</periods_cnt>
</graph_element>
<graph_element item="Exim4-stats:exim4[frozen]">
<drawtype>1</drawtype>
<sortorder>2</sortorder>
<color>FF3333</color>
<yaxisside>0</yaxisside>
<calc_fnc>2</calc_fnc>
<type>0</type>
<periods_cnt>5</periods_cnt>
</graph_element>
</graph_elements>
</graph>
</graphs>
<macros/>
</host>
</hosts>
<dependencies/>
</zabbix_export>

Затем прикрепляем шаблон к нужному узлу сети и настраиваем триггеры, например, на превышение писем в очереди.