Pflogsumm for Postfix Monitoring on CentOS 6

Traducciones al Español
Estamos traduciendo nuestros guías y tutoriales al Español. Es posible que usted esté viendo una traducción generada automáticamente. Estamos trabajando con traductores profesionales para verificar las traducciones de nuestro sitio web. Este proyecto es un trabajo en curso.
Create a Linode account to try this guide with a $ credit.
This credit will be applied to any valid services used during your first  days.

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.

Email restrictions on the Linode Platform
In an effort to fight spam originating from our platform, outbound connections on ports 25, 465, and 587 are blocked by default on Compute Instances for some new accounts. These restrictions prevent applications from sending email. If you intend to send email from a Compute Instance, review the Send Email on the Linode Platform guide to learn more about our email policies and to request the removal of these restrictions.

Before You Begin

Note
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:

  • Postfix
  • Perl 5.004
  • Perl’s Date::Calc module

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.

Installing Pflogsumm

In this section, you will install and configure Pflogsumm.

  1. Use wget to download Pflogsumm at /usr/local directory:

    sudo wget -O http://jimsun.linxnet.com/downloads/pflogsumm-1.1.3.tar.gz /usr/local/pflogsumm-1.1.3.tar.gz
    
  2. Expand the files:

    sudo tar -xzf /usr/local/pflogsumm-1.1.3.tar.gz
    
  3. Rename the Pflogsumm directory:

    sudo mv /usr/local/pflogsumm-1.1.3 /usr/local/pflogsumm
    
  4. Make the Pflogsumm directory executable:

    sudo chmod a+x /usr/local/pflogsumm/pflogsumm.pl
    

Testing

Test the script by running the following command. Make sure you substitute /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.

Reading Output

Your report output will contain the following information in an easy-to-read textual format perfect for email:

  • Total number of:
    • Messages received, delivered, forwarded, deferred, bounced and rejected
    • Bytes in messages received and delivered
    • Sending and Recipient Hosts/Domains
    • Senders and Recipients
    • Optional SMTPD totals for number of connections, number of hosts/domains connecting, average connect time and total connect time
  • 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

  • Sorted in descending order:
    • Recipient Hosts/Domains by message count, including:
      • Number of messages sent to recipient host/domain
      • Number of bytes in messages
      • Number of defers
      • Average delivery delay
      • Maximum delivery delay
    • 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.

  • A Semi-Detailed Summary of:
    • Messages deferred
    • Messages bounced
    • Messages rejected
  • 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.

Scheduling Reports with Cron

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.

  1. Open the root user’s Crontab by running the following command:

    sudo crontab -e
    
  2. 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.

    root's Crontab
    
    Note
    If this is your first time using Cron, you will have to select your preferred text editor.
  3. Save the changes to your Cron file. For nano, this is Ctrl-x y.

    Note
    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.

More Information

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 page was originally published on


Your Feedback Is Important

Let us know if this guide was helpful to you.


Join the conversation.
Read other comments or post your own below. Comments must be respectful, constructive, and relevant to the topic of the guide. Do not post external links or advertisements. Before posting, consider if your comment would be better addressed by contacting our Support team or asking on our Community Site.
The Disqus commenting system for Linode Docs requires the acceptance of Functional Cookies, which allow us to analyze site usage so we can measure and improve performance. To view and create comments for this article, please update your Cookie Preferences on this website and refresh this web page. Please note: You must have JavaScript enabled in your browser.