pflogsumm Mail reports
pflogsumm is a simple yet great mail summary reporting tool. You can install it using aptitude.
Features/Tasks and Limitations
- Emails report via cron
- Keeps 40 days worth of reporting at /var/log/postfixrep
- Limitation: Since log rotate does not do a daily rotation, reports will overlap!
- This is not an issue with systemd
- Update email: system@example.com
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