gweth check

gweth check

 

# Start
/etc/config/ditel_gweth.sh &

# Kill
killall ditel_gweth.sh

 

# Type 9 AnovoSatBox 192.168.0.1

#!/bin/sh
#filename: ditel_gweth.sh

GWTYPE=9
GWIP='192.168.0.1'

GWETH='eth0'
GWLOG='/tmp/gweth.log'
PINGOUT='/tmp/ping.out'


#gweth_restart eth0 192.168.0.1 2 10 6
gweth_restart()
{
    ethx=$1
    ipaddr=$2
    timeout=$3
    sum=$4
    min=$5
    sleep 1
    ping $ipaddr -W $timeout -c $sum > $PINGOUT 2>&1
    m=`cat $PINGOUT | grep 'bytes from' | wc -l`
    echo "`date +"%Y/%m/%d %H:%M:%S"` ping test. all = $sum, min = $min, ok = $m." >>$GWLOG 2>&1
    if [ $m -lt $min ]
    then
        ethx=eth0
        ethtool -s $ethx speed 10 duplex half autoneg on > /dev/null 2>&1
        sleep 3
        ethtool -s $ethx speed 100 duplex full autoneg on > /dev/null 2>&1
        sleep 3
        echo "`date +"%Y/%m/%d %H:%M:%S"` $ethx restart" >>$GWLOG 2>&1
        return 1
    else
        echo "`date +"%Y/%m/%d %H:%M:%S"` $ethx health" >>$GWLOG 2>&1
        return 0
    fi
}

### ( Main )

GWTYPE=`uci get Set_Modem_Type.Modem_Type.Modem_Type`
if [ $GWTYPE -eq 9 ]; then
    GWIP=`uci get Set_Modem_Type.Modem_Type.SatBox_Server_IP`
    while true
    do
        sleep 1
        gweth_restart $GWETH $GWIP 2 10 6
        line=`wc -l $GWLOG | cut -d' ' -f1`
        [ $line -gt 20 ] && cat /dev/null > $GWLOG
    done
fi

exit 0

### ( End )

 

============ End

 

posted @ 2024-12-30 16:19  lsgxeva  阅读(4)  评论(0编辑  收藏  举报