This is a Linode Community guide by author Robert Accettura. Write for us and earn $100 per published guide.
Pflogsumm is a simple Perl script that monitors your Postfix mail server's activity. This guide will show you how to install Pflogsumm on CentOS 6 and configure it to send you a daily email with your mail server stats.
This guide is written for a non-root user. Commands that require elevated privileges are prefixed with sudo. If you're not familiar with the sudo command, you can check our Users and Groups guide.
Make sure these prerequisites are installed:
Perl 5.004 will most likely be installed by default. Run this command to install the Date::Calc module:
sudo yum install perl-Date-Calc
Finally, you will need to locate your Postfix log. On most CentOS systems, this is /var/log/maillog by default.
In this section, you will install and configure Pflogsumm.
Move to the /usr/local directory:
sudo cd /usr/local/
Use curl to download Pflogsumm:
sudo curl -O http://jimsun.linxnet.com/downloads/pflogsumm-1.1.3.tar.gz
Expand the files:
sudo tar -xzf pflogsumm-1.1.3.tar.gz
Rename the Pflogsumm directory:
sudo mv pflogsumm-1.1.3 pflogsumm
Make the Pflogsumm directory executable:
sudo chmod +x pflogsumm/pflogsumm.pl
Test the script by running the following command. Make sure you subsitute /var/log/maillog with your actual Postfix log location.
sudo perl /usr/local/pflogsumm/pflogsumm.pl /var/log/maillog
You will see a large amount of information regarding your mail server, which we'll go over in the next section.
Your report output will contain the following information in an easy-to-read textual format perfect for email:
Per-Day Traffic Summary (for multi-day logs)
Per-Hour Traffic (daily average for multi-day logs)
Optional Per-Hour and Per-Day SMTPD connection summaries
Sending Hosts/Domains by message and byte count
Optional Hosts/Domains SMTPD connection summary
Senders by message count
Recipients by message count
Senders by message size
Recipients by message size with an option to limit these reports to the top nn.
Summaries of warnings, fatal errors, and panics
Summary of master daemon messages
Optional detail of messages received, sorted by domain, then sender-in-domain, with a list of recipients-per-message.
Optional output of "mailq" run
This list was taken from the Pflogsumm website, where you can read additional information about the output.
Now you'll set up a Cron job to run the Pflogsumm Perl script and send the mail server stats to you as a daily email. This is great for monitoring your mail server. The example below schedules the email for 1:01 PM every day. For details on how to customize the time the email is sent, you should read the Cron article.
Open the root user's Crontab by running the following command:
sudo crontab -e
Add the following line, being sure to replace /var/log/maillog with the mail server location, and YOUREMAIL@YOURDOMAIN.TLD with the email address where you want to receive the stats. It's usually a good idea to choose an email address that's not on this Postfix server.
.. 1 13 * * * perl /usr/local/pflogsumm/pflogsumm.pl /var/log/maillog | mail -s "Mail Server Stats" YOUREMAIL@YOURDOMAIN.TLD
If this is your first time using Cron, you will have to select your preferred text editor.
Save the changes to your Cron file. For nano, this is Ctrl-x y.
Non-root users will not have permission to access the mail log.
You will now receive daily emails with your Postfix mail server stats. It's a great way to keep track of what your server is doing.
You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.
This guide is licensed under a Creative Commons Attribution-NoDerivs 3.0 United States License.
Last edited by Sharon Campbell on Wednesday, February 5th, 2014 (r4203).