Qmail Monitoring and managing scripts

scripts to create multiple tcp connection

Qmail Monitoring and managing scripts

 

1) Create Qmail Scripts to Delete Mail Domain and Take backup, I am using rsysnc command for Bakup to Remote Storage system and if Get Confirm that backup is done scripts start deletion process.

#/bin/bash

#written by vikash kushwaha

#How to take backup and deleted Qmail Domain
LOG=/tmp/domain_backup_delete.txt
while read domain
do
/usr/bin/rsync -ar /data/mailstore/$domain

192.168.200.xx:/usb_backup/delete_domain_backup/
if test $? -eq 0
then
echo "Qmail.3 Backup sync to USB backup drive: Successfull" >> $LOG
rm -rf /data/mailstore/$domain;echo "$domain---deleted">>$LOG
else
echo " QMail.3 backup sync to USB Backup drive: Error" >> $LOG

fi
done</tmp/domain_list.txt

2) Set mail alert On Qmail System to Send mails to Admin Mail ID about Qmail Qmail Queue status.

#/bin/bash

#check internet conection on sahara .co.in server-----start*
OUTPUT=/tmp/internet.bash
DATE=`date "+%d%m%y_%X"`
TXTOUT=/tmp/Qmail_status.txt
wget -q --tries=10 --timeout=20 --spider http://google.com
if [[ $? -eq 0 ]]; then
# echo "Online"
echo "cat /server_dot3_log/Qmail_status.txt | mail -s \"Internet status::OK(sahara.co.in):$DATE\" [email protected] [email protected]" >/$OUTPUT
STATUS="Internet is running on this Server:::"
else
# echo "Offline"
echo "cat /server_dot3_log/Qmail_status.txt | mail -s \"Internet status::NOT RUNNING:(sahara.co.in):$DATE\" [email protected] [email protected] [email protected]" >/$OUTPUT
STATUS="Internet is NOT running on this Server:::"
fi

#check internet conection on sahara .co.in server----End*
#TXTOUT=/tmp/Qmail_status.txt
#check Server Status----------------Start
echo "Qmail .3 Mail queueStattus..$DATE" >$TXTOUT;/usr/bin/qmHandle -s >>$TXTOUT
/bin/df -h | grep var | cut -d " " -f22,23 >>$TXTOUT
/bin/df -h | grep data | cut -d " " -f29,30 >>$TXTOUT
/usr/bin/uptime | cut -d "," -f3,4,5 >>$TXTOUT
echo "$STATUS" >>$TXTOUT
path=/opt/spam_log
spam_date=`date '+%d%b%y'`
Count_Spam="$(cat $path/$spam_date | wc -l)"
echo "Total Spam deletd Now::$Count_Spam" >>$TXTOUT

3) Qmail mailbox Size calculator.

#/bin/bash
#bin/bash

find /data/mailstore/*/* -maxdepth 1 -type d >/tmp/account.txt
# 1043 cat /tmp/account.txt | cut "/" -f1,2
cat /tmp/account.txt | cut -d "/" -f"1","2","3","4","5" |uniq >/tmp/count_account.txt

while read line
do
Get_Size="$(/usr/bin/du -sh $line)"
echo "$Get_Size" >>/Qmail_Account_mbox_size_calculator.txt
done</tmp/count_account.txt

4) Qmail Account Calculator.

#bin/bash

find /data/mailstore/*/* -maxdepth 1 -type d >/tmp/account.txt
cat /tmp/count_account.txt | cut -d "/" -f1 |sort| uniq >/tmp/account.txt1
cat /tmp/count_account.txt | cut -d "/" -f2 |sort| uniq >/tmp/account.txt2
#echo "Total Domain..."
COUNT=$(cat /tmp/account.txt1 | wc -l)
COUNT1=$(cat /tmp/account.txt2 | wc -l)
echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
echo -n "***Total Domain...$COUNT";echo -n "***Total Mail Accounts....$COUNT1";echo " V"
echo "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"

for (( i=1; i<=$COUNT; i++))
do
getline=$(sed -n "$i p" /tmp/account.txt1)
echo -n "$getline"";";echo "$(grep $getline /tmp/count_account.txt | wc -l)"
done

5) Qmail Spam Calculator .

#!/bin/bash
#written by vikas
path_spam=/opt/spam_log
ls -1rt $path_spam >/tmp/filename.txt
#file_name=`date '+%d%b%y'`

COUNT=$(ls -1 $path_spam| wc -l)

for ((i=1; i<=$COUNT; i++))
do
filename=$(/bin/sed -n "$i p" /tmp/filename.txt)
echo -n "$filename;"
echo $(cat $path_spam/$filename | /usr/bin/wc -l)
done

Leave a Reply

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