Posts Tagged ‘greylisting’
If you use Postgrey (and you should do it) on your mail servers and you want to have some statistics on the amount of greylisted messages and other information, you should find useful the following script.
The scripts assume that you have installed Postgrey (http://postgrey.schweikert.ch/) on RHEL (http://www.redhat.com) or CentOS (http://www.centos.org).
If you are using other distros you may fix some path problems.
Create a file called “greylisting_statistics.sh” in your “/usr/local/bin” folder with the following content :
#!/bin/sh
LOGFILE=/tmp/greylist-statistics
YOURMAIL=you@yourdomain.com
echo -n "Total amount of GreyListed messages" > $LOGFILE
cat /var/log/maillog | /usr/sbin/postgreyreport --delay=300 >> $LOGFILE
echo -ne "\n" >> $LOGFILE
echo -ne "-------------------------------------\n" >> $LOGFILE
echo -ne "-------------------------------------\n" >> $LOGFILE
echo -n "Get only the top 20 sources getting greylisted out" >> $LOGFILE
cat /var/log/maillog | postgreyreport | awk '{print $1}' | sort | uniq -c | sort -nr | head -n20 >> $LOGFILE
echo -ne "\n" >> $LOGFILE
echo -ne "-------------------------------------\n" >> $LOGFILE
echo -ne "-------------------------------------\n" >> $LOGFILE
echo -n "Get a list of the top 20 email address that the greylisted sources are sending email to" >> $LOGFILE
cat /var/log/maillog | postgreyreport | awk '{print $4}' | sort | uniq -c | sort -nr | head -n20
echo -ne "\n" >> $LOGFILE
echo -ne "-------------------------------------\n" >> $LOGFILE
echo -ne "-------------------------------------\n" >> $LOGFILE
cat $LOGFILE | mail -s "Greylisting Statistics of `hostname` for `date +%Y-%m-%d`" $YOURMAIL
#--- End of file ---
Assign to it the correct ownership and permission by running :
chmod 700 /usr/local/bin/greylisting_statistics.sh chown root:root /usr/local/bin/greylisting_statistics.sh
Schedule the execution using “crontab -e” and adding the following line to have a daily based statistics :
59 23 * * * /usr/local/bin/greylisting_statistics.sh
Hope this help
Bye
Riccardo
Print This Post























