代码拉取完成,页面将自动刷新
#!/bin/bash
if [[ $# < 3 ]]; then
echo "Example: $0 smtp.163.com 1 5"
exit
fi
host=$1
duration=$2
count=$3
con_fails=0
fail=0
total=0
smtpserver=smtp.163.com
smtpport=25
user=13436881186@163.com
password=mlspoghvmazimtsh
fromemail=13436881186@163.com
toemail=33493248@qq.com
while true; do
echo -e "\r \c"
echo -e "\rTotal Fails:\033[36m $fail \033[0m Total Pings:\033[36m $total \033[0m Contineous Fails:\033[36m $con_fails \033[0m\c"
((total++))
ping -c 1 $host 2> /dev/null | grep "64 bytes from" > /dev/null
if [[ $? = "1" ]]; then
((con_fails++))
((fail++))
if [[ $con_fails = "$count" ]]; then
echo -e "\n\nFail to connect to host $host at `date`."
echo "Sending email to $toemail..."
python ./sendmail.py -n $smtpserver -p $smtpport --user $user --passwd $password -f $fromemail -t $toemail -s "不能连接主机$host at `date`" -c "链接主机失败:$host at `date`"
exit
fi
else
con_fails=0
fi
sleep ${duration}s
done
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。