#!/bin/bash
#Author: wang
#Date: 20170825

for ip in "192.168.101.28"
do
ping -c 1 $ip &>/dev/null #三个ping有一个能通,说明服务器正常
a=$?
sleep 2
ping -c 1 $ip &>/dev/null
b=$?
sleep 2
ping -c 1 $ip &>/dev/null
c=$?
sleep 2
DATE=$(date +%F" "%H:%M)
if [ $a -ne 0 -a $b -ne 0 -a $c -ne 0 ];then

/usr/local/bin/sendEmail -f wangdonghui@163.com wangdonghui@wang.com -s smtp.163.com -u "Ping $ip online failed"
-o message-content-type=html -o message-charset=utf8 -xu wangdonghui@163.com -xp 密码
-m "Date : $DATE\nHost : $ip\nProblem : Ping is failed." >> /opt/shell/crontab/ping.log

#else
# echo "$ip ping is successful."
fi
done

相关文章:

  • 2021-07-18
  • 2021-08-31
  • 2021-12-29
  • 2022-02-03
  • 2022-01-02
  • 2021-05-21
猜你喜欢
  • 2022-02-09
  • 2021-05-01
  • 2021-06-02
  • 2021-04-25
  • 2021-11-18
  • 2021-08-31
相关资源
相似解决方案