解答:
#!/bin/bashrmail=12345@qqcom
export LANG=zh_CNUTF-8
ping -c50 192168110 >/tmp/pingtxt
if [ "$" != "0" ]; then
echo "`date +"%Y-%m-%d %H:%M:%S"` IP地址:192168110 网络不通,请检查网络!" >>/tmp/pkglosstxt
mail -s "测试IP网络异常报警" $rmail</tmp/pkglosstxt
fi
loss1=`cat /tmp/pingtxt |grep loss|awk '{print $6}'|awk -F% '{print $1}'`
if [ $loss1 -gt 40 ]; then
echo "`date +"%Y-%m-%d %H:%M:%S"` IP地址:192168110 丢包率超过40" >>/tmp/pkglosstxt
mail -s "测试IP网络异常报警" $rmail</tmp/pkglosstxt
fi
if [ $loss1 -gt 80 ]; then
echo "`date +"%Y-%m-%d %H:%M:%S"` IP地址:192168110 丢包率超过80" >>/tmp/pkglosstxt
mail -s "测试IP网络异常报警" $rmail</tmp/pkglosstxt
fi
echo "" >/tmp/pkglosstxt:
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)