How to get mail statistics from your postfix mail logs

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.5.tar.gz
  •  tar -zxf pflogsumm-1.1.5.tar.gz
  • chown root:root pflogsumm-1.1.5

Generate the statistics  :-

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

Grand Totals
————
messages

118 received
319 delivered
1 forwarded
6 deferred (1597 deferrals)
18 bounced
20 rejected (5%)
0 reject warnings
0 held
0 discarded (0%)

5452k bytes received
277987k bytes delivered
76 senders
49 sending hosts/domains
128 recipients
37 recipient hosts/domains

Per-Day Traffic Summary
date received delivered deferred bounced rejected
——————————————————————–
Jan 13 2018 51 251 476 14 9
Jan 14 2018 17 16 522 2 5
Jan 15 2018 43 45 527 2 6
Jan 16 2018 7 7 72

Per-Hour Traffic Daily Average
time received delivered deferred bounced rejected
——————————————————————–
0000-0100 0 1 19 0 0
0100-0200 1 1 13 0 0
0200-0300 1 1 13 0 0
0300-0400 1 1 19 0 0
0400-0500 1 1 14 0 0
0500-0600 0 0 7 0 0
0600-0700 1 1 13 0 0
0700-0800 1 1 13 0 0
0800-0900 0 0 7 0 0
0900-1000 2 2 14 0 1
1000-1100 5 51 32 3 0
1100-1200 1 1 33 0 0
1200-1300 1 4 14 0 0
1300-1400 2 2 20 0 0
1400-1500 2 2 20 0 0
1500-1600 4 4 14 0 0
1600-1700 1 1 20 0 0
1700-1800 2 2 20 0 1
1800-1900 1 2 14 1 0
1900-2000 1 1 13 0 2
2000-2100 1 1 19 0 0
2100-2200 1 1 19 0 0
2200-2300 1 1 13 0 0
2300-2400 1 1 19 0 1