Windows XP Windows 7 Windows 2003 Windows Vista Windows教程綜合 Linux 系統教程
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟件教程
 Windows教程網 >> Linux系統教程 >> Linux教程 >> Linux磁盤空間監控的Shell腳本

Linux磁盤空間監控的Shell腳本

日期:2017/2/7 14:33:24      編輯:Linux教程
 

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

Copyright © Windows教程網 All Rights Reserved