GFW/Monitor

GFW/Monitor

翻墙监控脚本

#!/bin/sh

LOGTIME=$(date "+%Y-%m-%d %H:%M:%S")
curl --connect-timeout 5 -s -I www.t66y.com/index.php > /dev/null
if [ "$?" == "0" ]; then
    echo '['$LOGTIME'] No Problem.'
    exit 0
else
    curl --connect-timeout 3 -s -I www.baidu.com > /dev/null
    if [ "$?" == "0" ]; then
        echo '['$LOGTIME'] Problem decteted.'
        # do something such as restart vpn
    else
        echo '['$LOGTIME'] Network Problem. Do nothing.'
    fi
fi

Script 2

#!/bin/sh

while [ 1 ]
do
    LOGTIME=$(date "+%Y-%m-%d %H:%M:%S")
    curl --connect-timeout 5 -s -I www.t66y.com/index.php > /dev/null
    if [ "$?" == "0" ]; then
        echo '['$LOGTIME'] No Problem.'
        sleep 300
    else
        curl --connect-timeout 3 -s -I www.baidu.com > /dev/null
        if [ "$?" == "0" ]; then
            echo '['$LOGTIME'] Problem decteted.'
            # do something such as restart vpn
            sleep 500
        else
            echo '['$LOGTIME'] Network Problem. Do nothing.'
            sleep 120
        fi
    fi
done

Last update: 2018-04-29 02:01:34 UTC