1 Star 0 Fork 5

Mihok/wizard-scripts

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
keepalive 1.11 KB
一键复制 编辑 原始数据 按行查看 历史
南山一脚 提交于 2017-04-09 09:25 . add all scripts
#!/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
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Shell
1
https://gitee.com/Mihok/wizard-scripts.git
git@gitee.com:Mihok/wizard-scripts.git
Mihok
wizard-scripts
wizard-scripts
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385