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:
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:
Set the daemon to autostart on system boot
On SuSe or RedHat:
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.
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.)