SentinelOne Names LevelBlue Global Delivery Partner for Wayfinder Services. Learn More
Access immediate incident response support, available 24/7
The script below assumes that you have changed your /etc/logrotate.conf to do a daily rotation and that you are compressing and keeping 6 or more days of logs. Log in to your device as root crontab -e paste the following in (note that this text is in a scrolling region; please be sure you have copied all the text).
# created to email daily mail logs to users at 1:10am and weekly reports at 1:20am on Sundays # They are emailed to the local user postmaster, the email addresses are set in /etc/aliases # Once changes are made run 'postalias /etc/aliases' to update the system with the changes 0 1 * * * (zcat /var/log/maillog.1.gz ; cat /var/log/maillog ) |/usr/sbin/pflogsumm --problems_first -d yesterday -h 20 --no_no_msg_size -u20 | mail -s "`uname -n` daily mail stats for `date '+%F'`" postmaster 10 1 * * 0 (zcat /var/log/maillog.6.gz; zcat /var/log/maillog.5.gz; zcat/var/log/maillog.4.gz ; zcat /var/log/maillog.3.gz; zcat /var/log/maillog.2.gz;zcat /var/log/maillog.1.gz; cat /var/log/maillog) | /usr/sbin/pflogsumm--problems_first -h 20 --no_no_msg_size -u 20 |mail -s "`uname -n`weekly mail stats for `date --date="-7 days" +%F`" postmaster 20 1 1 * * (zcat /var/log/maillog.*.gz ; cat /var/log/maillog) |/usr/sbin/pflogsumm --problems_first -h 20 --no_no_msg_size -u 20 | mail -s" `uname -n`Monthly mail stats for `date --date="lastmonth" +%Y-%m`" postmaster
You can get a report that looks like the following example:
Postfix log summaries for Aug 18Grand Totals------------messages22 received17 delivered6 forwarded0 deferred0 bounced2 rejected (10%)0 reject warnings0 held0 discarded (0%)410520 bytes received416588 bytes delivered5 senders2 sending hosts/domains5 recipients2 recipient hosts/domainsmessage deferral detail: nonemessage bounce detail (by relay): nonemessage reject detail---------------------RCPTSender address rejected: Access denied (total: 2)2<>message reject warning detail: nonemessage hold detail: nonemessage discard detail: nonesmtp delivery failures: noneWarnings: noneFatal Errors: nonePanics: noneMaster daemon messages: nonePer-Hour Traffic Summarytime received delivered deferred bounced rejected--------------------------------------------------------------------0000-0100 0 0 0 0 0 0100-0200 1 1 0 0 1 0200-0300 0 0 0 0 0 0300-0400 0 0 0 0 0 0400-0500 1 1 0 0 1 0500-0600 0 0 0 0 0 0600-0700 0 0 0 0 0 0700-0800 0 0 0 0 0 0800-0900 7 4 0 0 0 0900-1000 13 11 0 0 0 1000-1100 0 0 0 0 0 1100-1200 0 0 0 0 0 1200-1300 0 0 0 0 0 1300-1400 0 0 0 0 0 1400-1500 0 0 0 0 0 1500-1600 0 0 0 0 0 1600-1700 0 0 0 0 0 1700-1800 0 0 0 0 0 1800-1900 0 0 0 0 0 1900-2000 0 0 0 0 0 2000-2100 0 0 0 0 0 2100-2200 0 0 0 0 0 2200-2300 0 0 0 0 0 2300-2400 0 0 0 0 0 Host/Domain Summary: Message Delivery sent cnt bytes defers avg dly max dlyhost/domain-------- ------- ------- ------- ------- -----------1223924 0 0.1s 1.0 s sup-domain1.com5392664 0 0.2s 1.0 s verincent.comHost/Domain Summary: Messages Received msg cnt bytes host/domain-------- ------- -----------10 399408 sup-domain1.com6 11112sup-protect-8-2.sup-domain1.comSenders by message count------------------------6 supcon-8-2@sup-domain1.com5 root@sup-protect-8-2.sup-domain1.com3 alavies@sup-domain1.com1 ALavies@sup-domain1.com1 verincent@sup-protect-8-2.sup-domain1.comRecipients by message count---------------------------6 alavies@sup-domain1.com5 adminstrator@sup-domain1.com3 alavies@verincent.com2 kconnel@verincent.com1 kconnel@sup-domain1.comSenders by message size-----------------------293394 alavies@sup-domain1.com98127 ALavies@sup-domain1.com9920 root@sup-protect-8-2.sup-domain1.com7887 supcon-8-2@sup-domain1.com1192 verincent@sup-protect-8-2.sup-domain1.comRecipients by message size--------------------------196739 alavies@verincent.com195925 kconnel@verincent.com11810 alavies@sup-domain1.com7048 adminstrator@sup-domain1.com5066 kconnel@sup-domain1.com=================================================
If you have any questions please contact TAC@trustwave.com.
To contact LevelBlue about this article or to request support: