Get Postfix Stats Easily

This post was migrated over from Muziboo DevBlog. Muziboo has a lot of emails going out everyday. For example, we notify people on new comments on their songs, email them their weekly stats or send them friendship requests (you can ofcourse turn off emails you don' want). Its very important to ensure delivery of these emails as a lot of our users depend on these notifications. 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 Technorati Tags: ,


blog comments powered by Disqus
Hana Mohan
Hana Mohan