Monitoring

Postfix

Monitoring Postfix is not quite as simple as many other applications, as the data is only in a log file. We will install a small daemon onto the system to watch the specified log file.

Note: While the scripts and procedures covered on this page will work in many situations, they are presented as an example only, and may require customization. They are easily modified to cover different versions of Linux; different mailers other than dovecot; different file locations, etc. If you need assistance with these matters, please contact LogicMonitor support.

These are the steps:

  • Ensure the Perl module File::Tail is installed on the host running Postfix. (Not covered in this document.)
  • Download postfixStats-updater.pl into /usr/local/logicmonitor/utils/ and chmod it to mode 755. This file runs as a daemon, and tails the specified log file, watching for Postfix operations and incrementing counters in a Berkeley DB.
  • Download the startup script postfixStats.init into /etc/init.d/. Chmod it to mode 775, and set the script to start on system boot
  • Download postfixStats-reporter.pl into /usr/local/logicmonitor/utils/ and chmod it to mode 755. This file is called by snmpd to report the data logged by the daemon.
  • Modify the snmpd configuration to run the reporting script when polled, and restart snmpd.
 SNMP daemon must run as root.
  • Wait for (or trigger) ActiveDiscovery so that the datasources to monitor the reported data are active

 

Quick Start Script

This script can be used on a host to complete the setup:

mkdir -p /usr/local/logicmonitor/utils/
cd /usr/local/logicmonitor/utils/
wget http://help.logicmonitor.com/code/postfixStats-updater.pl
wget http://help.logicmonitor.com/code/postfixStats-reporter.pl
chmod 755 postfixStats-*.pl
cd /etc/init.d/
wget http://help.logicmonitor.com/code/postfixStats.init
chmod 755 postfixStats.init
cat << EOF  >> /etc/snmp/snmpd.conf
extend postfix-recv-local  /usr/local/logicmonitor/utils/postfixStats-reporter.pl \
   recv:local
extend postfix-recv-smtp  /usr/local/logicmonitor/utils/postfixStats-reporter.pl \
   recv:smtp
extend postfix-sent-dovecot  /usr/local/logicmonitor/utils/postfixStats-reporter.pl \
   sent:dovecot
extend postfix-sent-local /usr/local/logicmonitor/utils/postfixStats-reporter.pl \
   sent:local
extend postfix-sent-smtp /usr/local/logicmonitor/utils/postfixStats-reporter.pl \
   sent:smtp
extend postfix-smtp-bounce /usr/local/logicmonitor/utils/postfixStats-reporter.pl \
   smtp:5xx
extend postfix-smtp-errorbounce /usr/local/logicmonitor/utils/postfixStats-reporter.pl \
   smtp:4xx
extend postfix-smtpd-rejected /usr/local/logicmonitor/utils/postfixStats-reporter.pl \
   smtpd:5xx
extend postfix-smtpd-errorbounce /usr/local/logicmonitor/utils/postfixStats-reporter.pl \
   smtpd:4xx
extend postfix-active /usr/local/logicmonitor/utils/postfixStats-reporter.pl active
extend postfix-deferred /usr/local/logicmonitor/utils/postfixStats-reporter.pl deferred

EOF
/etc/init.d/snmpd restart
/etc/init.d/postfixStats.init start  
 

Change location of monitored log file, if necessary

If /var/log/maillog is not the correct log file to track Postfix information on your system, modify the postfixStats-updater.pl file by editing the line that reads:

my $APPLOG = '/var/log/maillog'; 
 

Set the daemon to autostart on system boot

On Debian:

update-rc.d postfixStats.init defaults 

On SuSe or RedHat:

chkconfig postfixStats.init on
 

Activate the datasources

The datasources Postfix- and PostfixStatsProcess- should be part of your default datasources. If not, you can import them from the LogicMonitor repository.

The datasources will automatically discover if your devices are set up to report Postfix statistics - but that may take several hours. You can speed this up by Running Active Discovery on the devices that you have set these processes on.

You should then see two new datasource graphs - one monitoring the status of the daemon, and one monitoring the activity of Postfix.

 

Alerts

The Postfix- datasource only has 2 alerts defined - when active mail queue reaches 15,000 (75% of the default Postfix maximum); and when 50% of sent smtp mail is bouncing with a 5XX response code.
You can of course add other alerts, or adjust these, as appropriate.
PostfixStatsProcess- will trigger an error alert if the PostfixStats-updater process is not running.
The status of Postfix itself running is checked by the Port- datasource, as port 25 is one of the standard ports detected and alerted on. (You should confirm that port 25 is in the list of parameters to ad_port in the Active Discovery section of your Port- datasource.)