How to get mail statistics from your postfix mail logs

Overview :-

Last few years  i am supporting postfix mail servers. I would like to share one nice log diagnosing tool that I have used more ” Postfix Log Entry Summarizer

Its an amazing tool and will provide you the following details

  • 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

Installation :-

Installation is very simple , just download the package and unzip

  •  wget http://jimsun.linxnet.com/downloads/pflogsumm-1.1.1.tar.gz
  •  tar -zxf pflogsumm-1.1.1.tar.gz
  • chown root:root pflogsumm-1.1.1

 

Generate the statistics  :-

#  cat /var/log/maillog | ./pflogsumm.pl
( The above command will generate a detailed statistics as follows )

Grand Totals
————
messages

   1867   received
   3523   delivered
      0   forwarded
   707   deferred  (75  deferrals)
     35   bounced
    259  rejected (6%)
      0   reject warnings
      0   held
      0   discarded (0%)

  55528k  bytes received
  71732k  bytes delivered
     46   senders
     32   sending hosts/domains
    649   recipients
    350   recipient hosts/domains

Per-Day Traffic Summary
    date          received  delivered   deferred    bounced     rejected
    ——————————————————————–
    Jul 17 2011       257       2003       7295          8
    Jul 18 2011       471        352         94          2        216
    Jul 19 2011       986       1000        145         23         33
    Jul 20 2011       153        168         55          2         10

Per-Hour Traffic Daily Average
    time          received  delivered   deferred    bounced     rejected
    ——————————————————————–
    0000-0100           9          9          3          0          1
    0100-0200          11         10          4          1          4
    0200-0300          10         10          3          0          2
    0300-0400          11         13          3          0          2
    0400-0500          16         82        287          1          2

I am sure this will be definitely helpful for somebody who is working with postfix mail servers.

  • TMaGmA

    Perfect! Many thanks for sharing! Regards

  • Putu Nano

    Thx man. It help a lot 😉

  • Nathan

    good script. how do i limit the amount of lines in each function? e.g.. if i need to view only top 10 domains, how do i limit this?

  • nathan

    alright. i found out. thank you.

  • Thierry

    Thanks man, just what I needed 😉

  • mob24

    Thank GOD, i found this script 🙂

  • BenKai

    THANK YOU for sharing this, awesome little script

  • sree

    How did you limit count?

  • Cidious Romeous

    Hi.
    Very usefull script.

    Maybe what I’m looking for can’t be done, since your script is so complete and the information I’m searching doesn’t seem to be an option.

    I would like to count the outgoing message sent by domain.

    By outgoing I mean the messages that originate in SMTP users or local sending like sendmail.

    The perfect solution would be to count the messages sent by each authenticated user regardless of the the from address. Counting or not the internal/local messages (from and to internal addresses) wouldn’t be important.

    Maybe it can’t be done with the postfix log.

    Anyway thank you for this useful script.

    Cheers.

  • pdwalker

    I found this script last year. I forgot to say “Thank you”.

    Well, thank you. It’s very useful and well documented.

  • Sogood

    Thank you !!!

    How do you limit to top 10 domains ?

  • Kel

    I also needed to stop by and say “THANK YOU” fantastic tool for troubleshooting!

  • Forkbeard

    Four years since and still very useful. Thank you!