Outils pour utilisateurs

Outils du site


Panneau latéral

linux:zabbix:postfix (lu 17815 fois)

Postfix Statistics with Zabbix

This is a nice way to take postfix mail stats and input them into Zabbix.

There are a few shortcomings to this method as for data representation, but it is still a very efficient way to get the data into zabbix on busy mail servers.

Needed programs:

Install steps:

  1. Install pflogsumm and logtail on the host you want to monitor
  2. Create items in zabbix for pfreceived, etc etc (as you see in the bash script below). Remember we are using zabbix_sender so the items have to be of type “ZABBIX trapper”
  3. Save the bash script onto the host you want to monitor and modify the script where necessary
  4. Create a crontab line as described below
  5. Update zabbix_agentd.conf per below and create associated item as active check.
  6. importer le template dans zabbix zbx_postfix_template.xml

CODE

crontab line:

0/30 * * * * root   /usr/local/sbin/zabbix-postfix.sh

zabbix-postfix.sh:

zabbix-postfix.sh
#!/bin/bash
 
MAILLOG=/var/log/mail.log
DAT1=/tmp/zabbix-postfix-offset.dat
DAT2=$(mktemp)
PFLOGSUMM=/usr/sbin/pflogsumm
ZABBIX_CONF=/etc/zabbix/zabbix_agentd.conf
 
function zsend {
  /usr/bin/zabbix_sender -c $ZABBIX_CONF -k $1 -o $2
}
 
/usr/sbin/logtail -f$MAILLOG -o$DAT1 | $PFLOGSUMM -h 0 -u 0 --bounce_detail=0 --deferral_detail=0 --reject_detail=0 --no_no_msg_size --smtpd_warning_detail=0 > $DAT2
 
zsend pfreceived `grep -m 1 received $DAT2|cut -f1 -d"r"`
zsend pfdelivered `grep -m 1 delivered $DAT2|cut -f1 -d"d"`
zsend pfforwarded `grep -m 1 forwarded $DAT2|cut -f1 -d"f"`
zsend pfdeferred `grep -m 1 deferred $DAT2|cut -f1 -d"d"`
zsend pfbounced `grep -m 1 bounced $DAT2|cut -f1 -d"b"`
zsend pfrejected `grep -m 1 rejected $DAT2|cut -f1 -d"r"`
zsend pfrejectwarnings `grep -m 1 "reject warnings" $DAT2|cut -f1 -d"r"`
zsend pfheld `grep -m 1 held $DAT2|cut -f1 -d"h"`
zsend pfdiscarded `grep -m 1 discarded $DAT2|cut -f1 -d"d"`
zsend pfbytesreceived `grep -m 1 "bytes received" $DAT2|cut -f1 -d"b"`
zsend pfbytesdelivered `grep -m 1 "bytes delivered" $DAT2|cut -f1 -d"b"`
 
rm $DAT2

zabbix_agentd.conf line:

UserParameter=pfmailq,mailq | grep -v "Mail queue is empty" | grep -c '^[0-9A-Z]'
linux/zabbix/postfix.txt · Dernière modification: 24-06-2014 15:20 de edmc73