Table of Contents

pflogsumm Mail reports

pflogsumm is a simple yet great mail summary reporting tool. You can install it using aptitude.

Features/Tasks and Limitations

cron job to do daily reporting

Create a directory

mkdir /var/log/postfixrep 

Cron Script using systemd/journalctl

#!/bin/bash
#
# Daily Postfix Log report
#
TS=$(date +%Y%m%d_%H%M%S);
LOGFILEDIR="/var/log/postfixrep"
LOGFILE="$LOGFILEDIR/pfrep_$TS.txt"
PFLOGSUMM="/usr/local/bin/pflogsumm"
#
REMAIL="system@example.org"
REPSUB="Postfix Report"
#
journalctl _UID=`id -u postfix` -S yesterday -U today --no-pager | $PFLOGSUMM --detail 10 --problems_first --verbose_msg_detail > $LOGFILE
cat $LOGFILE | mailx -s "$REPSUB" $REMAIL
#
/usr/bin/find $LOGFILEDIR/pfrep* -mtime +40 -exec rm {} \;
#
exit 0

Cron Script using /var/log/mail

#!/bin/bash
#
# Daily Postfix Log report
#
TS=$(date +%Y%m%d_%H%M%S);
LOGFILEDIR="/var/log/postfixrep"
LOGFILE="$LOGFILEDIR/pfrep_$TS.txt"
PFLOGSUMM="/usr/sbin/pflogsumm"
PFMAILINF="/var/log/mail.info"
PFMAILINF="/var/log/mail.log"
REMAIL="system@example.com"
REPSUB="Postfix Report"
#
$PFLOGSUMM $PFMAILINF > $LOGFILE
cat $LOGFILE | mailx -s "$REPSUB" $REMAIL
#
/usr/bin/find $LOGFILEDIR/pfrep*.txt -mtime +367 -exec rm {} \;
#
exit 0