forked from Hubbitus/shell.scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcorbinaHolder
executable file
·51 lines (44 loc) · 1.07 KB
/
corbinaHolder
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
#many times is situation interface is up, but network not working!. So, switch to ping-check
#HOLD_IFACE=ppp0
#Интервал проверок, секунд
CHECK_INTERVAL=120
PING_HOST='ya.ru'
#PING_GW='10.121.0.17'
PING_GW='10.41.0.1'
LOGFILE='/root/corbinaHolder.LOG'
{
#ping -c1 -a $PING_HOST &>/dev/null
PING_status=0
goodCount=0
globalGoodCount=0
hangupCount=0
echo -n "Запуск мониторинга соединения: " && date
while [ true ];
do
ping -c2 -W50 -a $PING_HOST &>/dev/null
PING_status=$?
if [ ! $PING_status -eq 0 ]; then
(( hangupCount++ ))
echo
echo "Corbina not worked! This is $hangupCount time. Restarting. "`date`
#Now Ping Local GW
ping -c2 -a $PING_GW
echo "Ping Local GW result: $?;"
#Restart connection
/sbin/ifdown corbina ; /sbin/ifup corbina
goodCount=0
date
else
if [ $globalGoodCount -gt $goodCount ]; then
echo -n ".$goodCount($globalGoodCount)"
else
echo -n ".$goodCount"
fi
(( goodCount++ ))
(( globalGoodCount++ ))
fi
sleep $CHECK_INTERVAL
done
exit 0
} | tee -a $LOGFILE