監控磁盤空間大小並自動報警腳本

#!/bin/shide

#make by occardci

init()
{
IPADD=`ifconfig|grep 172.18|awk '{print $2}'|sed 's/addr://g'`;
NOWTIME=`date +%F-%H:%M`;
MAILTO="";
MAIL_SUB=" !**Report - Disk Capacity Report $NOWTIME **!";
tmpfile=/tmp/iamatmpfile.tmp
}it

mhead()
{
echo "" >$tmpfile;
echo "From :$IPADD" >>$tmpfile
echo "State :Report" >>$tmpfile
echo "ReportBy:$0" >> $tmpfile
echo "DateTime:$NOWTIME" >> $tmpfile
echo "Info :codfei" >> $tmpfile
echo "" >>$tmpfile;
}class

smail()
{
mail -s "$MAIL_SUB" $MAILTO < $tmpfileawk

}
init;sed

for x in `df | grep /dev | awk '{print $5}' | sed 's/%//g'`
dodate

if [ $x -gt 89 ]; then
mhead;
df -h >>$tmpfile;
smail;
exit 0;
fifile

donegrep

相關文章
相關標籤/搜索