码迷,mamicode.com
首页 > 其他好文 > 详细

磁盘监控报警并发邮件

时间:2019-08-02 09:17:49      阅读:116      评论:0      收藏:0      [点我收藏+]

标签:ifconf   lin   hang   percent   报警   line   eth   war   ddr   

#!/bin/sh
#auto disk monitor
#by zkg 2019-07-15

echo -e "\033[32m \033[1m"
rm -rf list.txt
LIST=df -h|grep "^/dev/" >> list.txt
cat << EOF

--------------磁盘监控报警----------------

EOF
echo -e "\033[32m \033[0m"
sleep 2

WEEK=date +%u
TIME=date

while read line
do
IP_ADDR=ifconfig eth1|grep "Bcast"|awk ‘{print $2}‘|awk -F: ‘{print $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 50 ];then
cat >email.txt <<EOF
*EMAIL*****
通知类型:告警
服务:Disk Monitor
主机:$IP_ADDR
状态:告警
日期/时间:
echo "周$WEEK $TIME"
额外信息:
CRITICAL - DISK MONITOR:$D_NAME Used more than ${D_PERCENT}%
EOF
echo -e "\033[32mthe $D_NAME has been used for more than ${D_PERCENT}%,please check.....\033[0m"
mail -s "$D_NAME warning" allen.zhang@ddty.com.cn < email.txt
fi

done <list.txt
echo -e "\033[32m---------------------------------------------\033[0m"
echo "Done."

磁盘监控报警并发邮件

标签:ifconf   lin   hang   percent   报警   line   eth   war   ddr   

原文地址:https://blog.51cto.com/1009516/2425814

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!