mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-03-09 15:40:03 +00:00
Test gateway before all
This commit is contained in:
parent
6dcc086948
commit
f9adb2e523
1 changed files with 25 additions and 19 deletions
|
@ -79,7 +79,6 @@ _restart
|
||||||
while true; do
|
while true; do
|
||||||
# setup tracker variables
|
# setup tracker variables
|
||||||
OMR_TRACKER_DEVICE_IP=
|
OMR_TRACKER_DEVICE_IP=
|
||||||
OMR_TRACKER_DEVICE_GATEWAY=
|
|
||||||
OMR_TRACKER_STATUS="ERROR"
|
OMR_TRACKER_STATUS="ERROR"
|
||||||
OMR_TRACKER_LATENCY=
|
OMR_TRACKER_LATENCY=
|
||||||
OMR_TRACKER_TIMEOUT=$((rto / 1000 + (rto % 1000 ? 1 : 0)))
|
OMR_TRACKER_TIMEOUT=$((rto / 1000 + (rto % 1000 ? 1 : 0)))
|
||||||
|
@ -90,24 +89,31 @@ while true; do
|
||||||
|
|
||||||
# execute specific tracker
|
# execute specific tracker
|
||||||
if [ -n "$OMR_TRACKER_DEVICE_IP" ]; then
|
if [ -n "$OMR_TRACKER_DEVICE_IP" ]; then
|
||||||
# setup loop variable
|
retgw=$(ping "$OMR_TRACKER_DEVICE_GATEWAY" \
|
||||||
tries="$OMR_TRACKER_TRIES"
|
-I "$OMR_TRACKER_DEVICE_IP" \
|
||||||
# loop until tries attempts have been reached
|
-w 1 \
|
||||||
while [ "$tries" -gt 0 ]; do
|
-c 1 \
|
||||||
ret=$(ping "$OMR_TRACKER_HOST" \
|
-q
|
||||||
-I "$OMR_TRACKER_DEVICE_IP" \
|
) && echo "$retgw" | grep -sq "0% packet loss" && {
|
||||||
-w "$OMR_TRACKER_TIMEOUT" \
|
# setup loop variable
|
||||||
-c 1 \
|
tries="$OMR_TRACKER_TRIES"
|
||||||
-q
|
# loop until tries attempts have been reached
|
||||||
) && echo "$ret" | grep -sq "0% packet loss" && {
|
while [ "$tries" -gt 0 ]; do
|
||||||
OMR_TRACKER_LATENCY=$(echo "$ret" | cut -d "/" -s -f4 | cut -d "." -f1)
|
ret=$(ping "$OMR_TRACKER_HOST" \
|
||||||
_update_rto "$OMR_TRACKER_LATENCY"
|
-I "$OMR_TRACKER_DEVICE_IP" \
|
||||||
OMR_TRACKER_STATUS="OK"
|
-w "$OMR_TRACKER_TIMEOUT" \
|
||||||
break
|
-c 1 \
|
||||||
}
|
-q
|
||||||
tries=$((tries - 1))
|
) && echo "$ret" | grep -sq "0% packet loss" && {
|
||||||
OMR_TRACKER_TIMEOUT=$((OMR_TRACKER_TIMEOUT * 2))
|
OMR_TRACKER_LATENCY=$(echo "$ret" | cut -d "/" -s -f4 | cut -d "." -f1)
|
||||||
done
|
_update_rto "$OMR_TRACKER_LATENCY"
|
||||||
|
OMR_TRACKER_STATUS="OK"
|
||||||
|
break
|
||||||
|
}
|
||||||
|
tries=$((tries - 1))
|
||||||
|
OMR_TRACKER_TIMEOUT=$((OMR_TRACKER_TIMEOUT * 2))
|
||||||
|
done
|
||||||
|
}
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue