, , ,

Get Postfix Stats Easily

This post was copied from another site, I found it usefull. We use postfix as our MTA and use google apps to receive emails. I was looking for a simple tool to parse postfix log and generate some daily stats and I found pflogsumm You simply need to download the gzip file, extract it and copy pflogsumm.pl in somewhere in your executable path (or you can execute it from any other directory) and make sure you run it as a user who has access to your mail.log file (/var/log/mail.log). Here is the command that you need to run

/usr/bin/pflogsumm -d yesterday /var/log/mail.log >> mailstats.txt

and you get neatly summarized stats for postfix. You can put it in a cron to generate stats automatically every day. A rule to generate logs every day just a minute before midnight would be

59 23 * * *  /usr/bin/pflogsumm -d yesterday /var/log/mail.log >> /PATH/TO/FOLDER/YOU/WANT/mailstats.txt

You can put this as the last line in your crontab, which is accessed by crontab -e