EMAIL_TO="[email protected]"
EMAIL_TO_B="[email protected]"
EMAIL_TO_C="[email protected]"
Disk_load=95
a=(`df |awk '{print $(NF-1)}'|sed -e 's/\%/ /'g|grep -v "Mounted"|grep -v "\/"`)
i=0
while [ $i -lt ${#a[@]} ]
do
if [ ${a[i]} -gt ${Disk_load} ]; then
IP_Addr=`/sbin/ifconfig|sed -n '/inet addr/s/^[^:]*:\([0-9.]\{7,15\}\) .*/\1/p'|head -1`
SendMail="警報,服務器IP: "${IP_Addr}" 硬盤空間已經使用:"${a[i]}%" "
MailTitle="Alarm, the server ip:"${IP_Addr}" hard disk space is used "${a[i]}%""
echo $SendMail | mail -s "$MailTitle" -c ${EMAIL_TO_B} ${EMAIL_TO} -- -f ${EMAIL_TO_C}
fi
i=`expr $i + 1`
done