Repair Qmail Log

Repair Qmail Queue log, if your server become irresponsible in term’s of getting more worning in Qmail log with no index found for given mail Trsn ID.

#!/bin/bash #Writter by vikas kushwaha #stop all incomine mails /sbin/iptables -A INPUT -p tcp --dport 25 -j REJECT #greped all corrept data from mail transictional log /bin/sleep 20 #grep -i "warning: unable to stat mess" /var/qmail/log/qmail/* | cut -d "/" -f8 >/tmp/corrept_mess.txt #grep -i "warning: unable to open todo" /var/qmail/log/qmail/* | cut -d "/" -f7 >>/tmp/corrept_mess.txt #grep -i "warning: unable to" /var/qmail/log/qmail/* | cut -d "/" -f8 | cut -d ";" -f1 >>/tmp/corrept_mess.txt #grep -i "warning: unable to" #cat /tmp/corrept_mess.txt |sort| uniq >/tmp/corrept_mess.txt #***********Repair Qmail log************ /usr/bin/qmailctl stop /usr/local/bin/queue_repair.py -r /usr/bin/qmailctl start /usr/bin/qmailctl doqueue /usr/bin/qmailctl flush #wait for 5 min to send all mails to distination. TOTAL=`/usr/bin/qmHandle -s | grep Total | cut -d " " -f3` REMOTE=`/usr/bin/qmHandle -s | grep remote | cut -d " " -f5` LOCAL=`/usr/bin/qmHandle -s | grep local | cut -d " " -f5` #this calculation is based on throughput, our mail server sending Avg. 4 mails per sec. Example 30Sec.X4=120, If all mails back to bounced then mail value will be 120/2 # 60 Message in 30 Sec. And +-10% Error, so perfect value will be 50 message should be delevery in 30 Sec. #if [ $TOTAL <= 50 ]; then tim=30 #elif [ $TOTAL <= 100 ]; then tim=60 #elif [ $TOTAL <= 200 ]; then tim=120 #elif [ $TOTAL >= 500 ]; then tim=300 #@else tim=10m #fi #/bin/sleep $tim /bin/sleep 30 grep -i "warning: unable to stat mess" /var/qmail/log/qmail/* | cut -d "/" -f8 >/tmp/corrept_mess.txt grep -i "warning: unable to open todo" /var/qmail/log/qmail/* | cut -d "/" -f7 >>/tmp/corrept_mess.txt grep -i "warning: unable to" /var/qmail/log/qmail/* | cut -d "/" -f8 | cut -d ";" -f1 >>/tmp/corrept_mess.txt #grep -i "warning: unable to" cat /tmp/corrept_mess.txt |sort| uniq >/tmp/corrept_mess.txt /usr/bin/qmailctl stop while read line do echo -n "Start find mail Unique ID......$line......." find /var/qmail/queue/ -name $line | xargs rm -f echo ".......Done" done #start Qmail if all process successfully run /usr/bin/qmailctl start #disable all newly restrictions, /etc/init.d/iptables restart

One comment

Leave a Reply

Your email address will not be published. Required fields are marked *