#!/bin/bash
#auto montor disk
#by authors zhj 2017
rm -rf list.txt
LIST=`df -h | grep "^/dev" >> list.txt`
cat << EOF
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++wclcome to use auto monitor system++++
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
EOF
echo -e "033[32m-----------------------\033[0m"
echo
sleep 2
while read line
do
IP_ADDR=`ifconfig eth0|grep "Bcast"|awk '{print $2}'|cut -d: -f 2`
D_Name=`echo $line|awk '{print $1,$NF"分区"}'`
D_Total=`echo $line|awk '{print $2}'`
D_Avail=`echo $line |awk '{print $4}'`
D_Percent=`echo $line |awk '{print $5}'|sed 's/%//g'`
if [ "$D_Percent" -ge 1 ];then
cat > email.txt <<EOF
********************************Email**************************
通知类型:故障
服务:Disk Monitor
主机:$IP_ADDR
状态:警告
日期/时间:周二 `date +%Y-%m-%d` 00时:15分:53秒 CST
额外信息:
CRITICAL - DISK Monitor:$D_Name Used more than ${D_Percent}%
EOF
echo -c "\033[32mThe $D_Name has been used for more then ${D_Percent}}% ,please Check.\033[0m "
mail -s "$D_Name Warning " zhangjia5551@126.com < email.txt
fi
done <list.txt
echo -e "\n\033[32m------------------------------------\033[1m"
echo "Done."