Once you're using Postgrey and what to see how it's working, install the following script somewhere on your server:
"postgrey_stats.sh"
Code:
#!/bin/sh
LOGFILE=/tmp/greylist-statistics
YOURMAIL=youremail@yourdomain.com
echo "Total amount of GreyListed messages
" > $LOGFILE
cat /var/log/mail.log | /usr/bin/postgreyreport --delay=300 >> $LOGFILE
echo -ne "-------------------------------------\n" >> $LOGFILE
echo -ne "-------------------------------------\n" >> $LOGFILE
echo "Get only the top 20 sources getting greylisted out
" >> $LOGFILE
cat /var/log/mail.log | postgreyreport | awk '{print $1}' | sort | uniq -c | sort -nr | head -n20 >> $LOGFILE
echo -ne "-------------------------------------\n" >> $LOGFILE
echo -ne "-------------------------------------\n" >> $LOGFILE
echo "Get a list of the top 20 email address that the greylisted sources are sending email to
" >> $LOGFILE
cat /var/log/mail.log | postgreyreport | awk '{print $4}' | sort | uniq -c | sort -nr | head -n20 >> $LOGFILE
echo -ne "-------------------------------------\n" >> $LOGFILE
echo -ne "-------------------------------------\n" >> $LOGFILE
cat $LOGFILE | mail -s "Greylisting Statistics of `hostname` for `date +%Y-%m-%d`" $YOURMAIL
Edit the following parts of the above script:
1) Change the "YOUREMAIL = " line so that it goes to your personal mail box. This will give you details on how its working.
2) Make sure that /var/log/mail.log is the correct path to your current mail.log file. Distros are different.
Set the script to chmod +700 so that it is executable.
Finally, create a cronjob so that it will give you an automatic output to your email daily (or whenever you choose).