Hi All,
thanks a ton for your script frater
I had to tweak it a bit in order to make it work. I use a compiled version of Zabbix (Version 1.8.3). The zabbix_sender binary requires extra argument. So I added two variables :
ZABBIX_HOST=The monitored server hostname (see /etc/zabbix/zabbix_agentd.conf)
ZABBIX_SERVER=The IP address of the Zabbix server
and at line 16 I added two arguments : the -s $ZABBIX_HOST and -z $ZABBIX_SERVER
Here is the final script :
I also changed the name for the postfix[recipients] item. The item was "postfix[bytes_recipient]" which is not the key send by the script (plus the item was meaningless
).
I also added a graph for that template (I set the unit to the collected values as "mails" except for the two items that return bytes), and 4 triggers which make sure the queue doesn't hold more than 400 mails, and I also check the deferred/ rejected mails.
Here is how the scoreboard looks like :

The template has been updated, you can download the attachment
zbx_templates_export.xml
thanks a ton for your script frater
I had to tweak it a bit in order to make it work. I use a compiled version of Zabbix (Version 1.8.3). The zabbix_sender binary requires extra argument. So I added two variables :ZABBIX_HOST=The monitored server hostname (see /etc/zabbix/zabbix_agentd.conf)
ZABBIX_SERVER=The IP address of the Zabbix server
and at line 16 I added two arguments : the -s $ZABBIX_HOST and -z $ZABBIX_SERVER
Here is the final script :
Code:
#!/bin/bash
MAILLOG=/var/log/mail.log
DAT1=/tmp/zabbix-postfix-offset.dat
DAT2=$(mktemp)
PFLOGSUMM=/home/john/pflogsumm.pl
ZABBIX_CONF=/etc/zabbix/zabbix_agentd.conf
ZABBIX_HOST=DA_FUNKY_SERVER
ZABBIX_SERVER=8.8.8.8
DEBUG=1
function zsend {
key="postfix[`echo "$1" | tr ' -' '_' | tr '[A-Z]' '[a-z]' | tr -cd [a-z_]`]"
value=`grep -m 1 "$1" $DAT2 | awk '{print $1}'`
[ ${DEBUG} -ne 0 ] && echo "Send key \"${key}\" with value \"${value}\"" >&2
/usr/local/bin/zabbix_sender -s $ZABBIX_HOST -z $ZABBIX_SERVER -c $ZABBIX_CONF -k "${key}" -o "${value}" 2>&1 >/dev/null
}
/usr/sbin/logtail -f$MAILLOG -o$DAT1 | $PFLOGSUMM -h 0 -u 0 --no_bounce_detail --no_deferral_detail --no_reject_detail --no_no_msg_size --no_smtpd_warnings > $DAT2
zsend received
zsend delivered
zsend forwarded
zsend deferred
zsend bounced
zsend rejected
zsend held
zsend discarded
zsend "reject warnings"
zsend "bytes received"
zsend "bytes delivered"
zsend senders
zsend recipients
rm $DAT2
).I also added a graph for that template (I set the unit to the collected values as "mails" except for the two items that return bytes), and 4 triggers which make sure the queue doesn't hold more than 400 mails, and I also check the deferred/ rejected mails.
Here is how the scoreboard looks like :

The template has been updated, you can download the attachment

zbx_templates_export.xml
Comment