#!/bin/bash
sys=`uname`
if [ "$sys" = "Linux" ];then
. ${HOME}/.bash_profile
else
. ${HOME}/.profile
fi
ALL_USER=/tmp/user.list
INFO_FILE=/tmp/uses_all.list
SEND_MAILa=/tmp/sendmail01.list
SEND_MAILb=/tmp/sendmail02.list
MAIL=/tmp/mail.list
LOG_FILE=/var/log/tmailer.log
dateStr=`date --date "1 days ago" +"%b %d"|sed 's/0/ /1'`
DEFDOMAIN=`uapi gacf | grep tmailerDefaultDomainName | awk '{print $2}'`
STMPHOSTNAME=`uapi gacf | grep tmailerSmtpHostname | awk '{print $2}'`
uapi -l gaa |grep -v admin |grep -v wiki|grep -v spam|grep -v ham > $ALL_USER
for USER in $(cat $ALL_USER | awk '{print $1}')
do
Num=0
grep "$dateStr" $LOG_FILE |grep $USER| grep from= |awk '{print $6}'> $INFO_FILE
for IDLIST in $(cat $INFO_FILE | awk '{print $1}')
do
AAA=`grep $IDLIST $LOG_FILE | grep to= | grep -v $DEFDOMAIN |wc -l`
AAA=`expr $Num + $AAA`
Num=$AAA
done
if [ $Num -gt 500 ];then
echo "$USER $Num" >> $SEND_MAILa
uapi ma $USER tmailerAccountStatus closed
mysql -NB -e "use treemana;update mailbox set current_mode='closed' where email='$USER';"
else
echo "$USER $Num" >> $SEND_MAILb
fi
done
if [ -s $SEND_MAILa ];then
cat $SEND_MAILa |awk '{print $1,($2)}'|sort -rgk2 >$MAIL
/opt/tmailer/bin/sendmail admin@$DEFDOMAIN admin@$DEFDOMAIN "More than 500 messages" $MAIL $STMPHOSTNAME
cat $MAIL
rm -f $SEND_MAILa
else
cat $SEND_MAILb |awk '{print $1,($2)}'|sort -rgk2| head -n5 >$MAIL
/opt/tmailer/bin/sendmail admin@$DEFDOMAIN admin@$DEFDOMAIN "The 5 largest volume of mail" $MAIL $STMPHOSTNAME
cat $MAIL
rm -f $SEND_MAILb
fi
chown -fR tmailer:tmailer /tmp/user.list
chown -fR tmailer:tmailer /tmp/uses_all.list
阅读(1485) | 评论(0) | 转发(0) |