Мой первый скрипт (map lan viewer). Shorewall на роутере
Создано: 06-07-2009 11:37:23  Метки: work pppd sysadmin
костыль для контроля за pppoe
#! /bin/bash
# v1.4 call from crontab every minute, check ping & send watchsee
pinghost='wood.ru'
timeq=`date +%Y-%m-%d" "%H-%M`
mymail='xxxxxxxxxx@xxxxxxxxxxx.ru'

if ping $pinghost -c1 >/dev/null 2>&1 ; then
    echo "PING $timeq">>pingi.txt                                       # all ok
else
    echo "NOPING $timeq">>pingi.txt                                     # noping, check pppoe
    if ! ip a|grep ppp0 >/dev/null ; then                               # no device
        if ! pgrep pppd >/dev/null ; then                               # no proc
            pon dsl-provider >/dev/null                                 # ppoe up
        fi
    fi
fi
if [ `date +%H%M` = "0000" ] ; then                                     # in midnight count nopings
    fl=0                                                                # flag
    while read line ; do
        if  [ `echo $line|cut -f1 -d" "` = "NOPING" ] ; then            # noping
            if [ $fl = 0 ] ; then
                fl=1
                error="NOPING from `echo $line|cut -f2,3 -d' '` to"     # point of nopings
            fi
        else
            if [ $fl = 1 ] ; then
                echo "$error `echo $line|cut -f2,3 -d' '`">>check.txt   # end of nopings
            fi
            fl=0
        fi
    done <pingi.txt                                                     # in next count pings for check hw
    echo "Summ of pings must be 1440, we have `cat pingi.txt |wc -l` pings" >> check.txt
    cat check.txt|mail -s"PINGI $HOSTMANE" $mymail                      # send email
    >pingi.txt                                                          # clear
    rm check.txt
fi
# end Птн 09 Май 2008 20:01:43
1485 просмотров комментировать

Мой первый скрипт (map lan viewer). Shorewall на роутере