标签:blob print while 状态 http ash git https ack
设计一个脚本,监控远程的一台机器(假设ip为192.168.208.1)的存活状态,当发现宕机时发一封邮件给你自己####参考答案
#!/bin/bash
n=ping -c5 192.168.208.1|grep ‘packet‘ |awk -F ‘%‘ ‘{print $1}‘ |awk ‘{print $NF}‘
if [ -z "$n" ]
then
echo "脚本有问题。"
python mail.py $m "检测机器存活脚本$0有问题" "获取变量的值为空"
exit
else
n1=echo $n|sed ‘s/[0-9]//g‘
if [ -n "$n" ]
then
echo "脚本有问题。"
python mail.py $m "检测机器存活脚本$0有问题" "获取变量的值不是纯数字"
exit
fi
fi
if br/>m=624665255@qq.com
while :
do
if [ $n -ge 50 ]
then
python mail.py $m "机器宕机" "丢包率是$n%"
fi
sleep 30
done
标签:blob print while 状态 http ash git https ack
原文地址:https://blog.51cto.com/9447803/2404065