群发quota报警邮件脚本
1、是群发邮件(通过`cat /log/aspera/warn_mail.txt`调用)
2、在邮件内容前增加自定义的3行(sed -e ‘1i Hi All,‘:在第1行前增加“Hi All,”;sed -e ‘2G‘:在第2行前增加空行)
#!/bin/bash
Date=`date +%Y%m%d`
Date2=`date +%Y%m%d -d "30 days ago"`
/bin/rm -rf /log/aspera/warn_mail.txt
/usr/bin/touch /log/aspera/warn_mail.txt
for I in `cat /log/aspera/warn_$Date.txt | awk -F[:" "]+ ‘{print $1}‘`
do
echo $I@ming.com >> /log/aspera/warn_mail.txt
done
echo zhi.yang@ming.com >> /log/aspera/warn_mail.txt
echo yang.qian@ming.com >> /log/aspera/warn_mail.txt
cat /log/aspera/warn_$Date.txt | sed -e ‘1i Hi All,‘ | sed -e ‘2i your quota of aspera(//10.0.1.4/asperadata) warn(>80%),please delete your no use data,thanks‘ | sed -e ‘2G‘ > /log/aspera/mail_context.txt
/usr/bin/mail -s "aspera(//10.0.1.240/asperadata) quota warn(>80%) users at $Date" `cat /log/aspera/warn_mail.txt` < /log/aspera/mail_context.txt
/bin/rm -rf /log/aspera/warn_$Date2.txt
本文出自 “linux” 博客,请务必保留此出处http://yangzhiming.blog.51cto.com/4849999/1893016
原文:http://yangzhiming.blog.51cto.com/4849999/1893016