- 论坛徽章:
- 0
|
#!/bin/sh
#Jiu Bu Gai Two Sheel.
#GAW OK=0,CNC OK=1,NET OK=2
_PATH="/etc"
log=/var/log/head.log
while [ "$OK" != "true" ]
do
cnc=`ping -c3 -t 1 218.26.213.145 | grep received | cut -d ' ' -f 4`
net=`ping -c3 -t 1 219.149.167.226 | grep received | cut -d ' ' -f 4`
if [ -s $_PATH/xian.conf ] ; then
xian=`cat $_PATH/xian.conf`
fi
if [ "$cnc" != "0" ] && [ "$net" != "0" ];then
if [ "$xian" = "0" ] ; then
echo `date "+DATE: %Y-%m-%d-%H:%M:%S"`------ GAW up! >> $log
else
echo `date "+DATE: %Y-%m-%d-%H:%M:%S"`------ GAW Tan! >> $log
echo 0 >$_PATH/xian.conf
## pfctl -f $_PATH/pf.conf
fi
OK="true"
elif [ "$cnc" != "0" ] ; then
if [ "$xian" = "1" ] ; then
echo `date "+DATE: %Y-%m-%d-%H:%M:%S"`------ cnc up! >> $log
else
echo `date`------ cnc Tan! >> $log
echo 1 >$_PATH/xian.conf
## pfctl -f $_PATH/cnc.conf
fi
OK="true"
elif [ "$net" != "0" ] ; then
if [ "$xian" = "2" ] ; then
echo `date "+DATE: %Y-%m-%d-%H:%M:%S"`------ net up! >> $log
else
echo `date "+DATE: %Y-%m-%d-%H:%M:%S"`------ net Tan! >> $log
echo 2 >$_PATH/xian.conf
## pfctl -f $_PATH/net.conf
fi
OK="true"
else
echo `date "+DATE: %Y-%m-%d-%H:%M:%S"`------ xian down! >> $log
sleep 1
fi
done
![]()
文件:
shuangxian.tar.gz
大小:
0KB
下载:
下载
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/32980/showart_329349.html |
|