mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-03-09 15:40:03 +00:00
Fixes and use nping for failover
This commit is contained in:
parent
f9adb2e523
commit
99881d1487
5 changed files with 18 additions and 21 deletions
|
@ -86,26 +86,21 @@ while true; do
|
|||
if [ -d "/sys/class/net/$OMR_TRACKER_DEVICE" ]; then
|
||||
# retrieve iface ip and gateway
|
||||
OMR_TRACKER_DEVICE_IP=$(ip -4 -br addr ls dev "$OMR_TRACKER_DEVICE" | awk -F'[ /]+' '{print $3}')
|
||||
OMR_TRACKER_DEVICE_GATEWAY_MAC=$(arp $OMR_TRACKER_DEVICE_GATEWAY | awk '{print $4}')
|
||||
|
||||
# execute specific tracker
|
||||
if [ -n "$OMR_TRACKER_DEVICE_IP" ]; then
|
||||
retgw=$(ping "$OMR_TRACKER_DEVICE_GATEWAY" \
|
||||
-I "$OMR_TRACKER_DEVICE_IP" \
|
||||
-w 1 \
|
||||
-c 1 \
|
||||
-q
|
||||
) && echo "$retgw" | grep -sq "0% packet loss" && {
|
||||
# setup loop variable
|
||||
tries="$OMR_TRACKER_TRIES"
|
||||
# loop until tries attempts have been reached
|
||||
while [ "$tries" -gt 0 ]; do
|
||||
ret=$(ping "$OMR_TRACKER_HOST" \
|
||||
-I "$OMR_TRACKER_DEVICE_IP" \
|
||||
-w "$OMR_TRACKER_TIMEOUT" \
|
||||
-c 1 \
|
||||
-q
|
||||
) && echo "$ret" | grep -sq "0% packet loss" && {
|
||||
OMR_TRACKER_LATENCY=$(echo "$ret" | cut -d "/" -s -f4 | cut -d "." -f1)
|
||||
# setup loop variable
|
||||
tries="$OMR_TRACKER_TRIES"
|
||||
# loop until tries attempts have been reached
|
||||
while [ "$tries" -gt 0 ]; do
|
||||
ret=$(arpping -c 1 \
|
||||
-r "$OMR_TRACKER_DEVICE" \
|
||||
-S "$OMR_TRACKER_DEVICE_IP" \
|
||||
-T "$OMR_TRACKER_HOST" \
|
||||
"$OMR_TRACKER_DEVICE_GATEWAY_MAC")
|
||||
) && echo "$ret" | grep -sq "Lost: 0 (0.00%)" && {
|
||||
OMR_TRACKER_LATENCY=$(echo "$ret" | awk '/Avg/{print $(NF)}' | sed 's:ms::')
|
||||
_update_rto "$OMR_TRACKER_LATENCY"
|
||||
OMR_TRACKER_STATUS="OK"
|
||||
break
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue