脚本监测多ISP链路实现自动切换(初级脚本)

  1 #!/bin/bash

  2
  3
  4 disconnect="0 received, 100% packet loss"
  5 connect="10 received, 0% packet loss"
  6
  7 #dianxintong="124.205.4.209"
  8 #guanghuan="119.253.36.33"
  9 liantong="202.106.58.18"
 10 #liantong="192.168.254.1"
 11
 12 #result0=`ping -c 10 $dianxintong`
 13 #result1=`ping -c 10 $guanghuan`
 14 result=`ping -c 10 $liantong`
 15
 16
 17 #echo $result0 > /root/szn/log/dianxintong_ping
 18 #echo $result1 > /root/szn/log/guanghuan_ping
 19 echo $result > /root/szn/log/liantong_ping
 20
 21
 22 #file0="/root/szn/log/dianxintong_ping"
 23 #file1="/root/szn/log/guanghuan_ping"
 24 file=/root/szn/log/liantong_ping
 25
 26 #jiance0=`grep $disconnect $file0`
 27 #jiance1=`grep $disconnect $file1`
 28 #jiance=`grep "100% packet loss" $file`
 29
 30 #echo $jiance0
 31 #echo $jiance1
 32
 33 [[ `grep "10 received, 0% packet loss" $file` ]]
 34 a=$?
 35 echo $a
 36 if [ $a = "1" ];  then
 37    /root/szn/telnet.sh
 38    echo "OK"
 39 else
 40    echo "Yes"
 41 fi
 42
 

你可能感兴趣的:(脚本监测多ISP链路实现自动切换(初级脚本))