1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-03-09 15:40:03 +00:00

Add wan http test to API

This commit is contained in:
Ycarus (Yannick Chabanois) 2021-03-23 09:49:12 +01:00
parent 57934483b7
commit 27979c78d3
8 changed files with 125 additions and 12 deletions

View file

@ -174,11 +174,10 @@ _httping() {
ret=$(httping "${host}" \
-y "${deviceip}" \
-t "$OMR_TRACKER_TIMEOUT" \
-c 1 \
-q
-c 1 2>&1
) && echo "$ret" | grep -sq "1 ok" && {
if [ "$localip" = "yes" ]; then
OMR_TRACKER_LATENCY=$(echo "$ret" | cut -d "/" -s -f5 | cut -d "." -f1)
OMR_TRACKER_LATENCY=$(echo "$ret" | cut -d "/" -s -f5 | cut -d "." -f1 | tr -d '\n')
_update_rto "$OMR_TRACKER_LATENCY"
fi
return
@ -187,11 +186,10 @@ _httping() {
ret=$(httping -l "${host}" \
-y "${deviceip}" \
-t "$OMR_TRACKER_TIMEOUT" \
-c 1 \
-q
-c 1 2>&1
) && echo "$ret" | grep -sq "1 ok" && {
if [ "$localip" = "yes" ]; then
OMR_TRACKER_LATENCY=$(echo "$ret" | cut -d "/" -s -f5 | cut -d "." -f1)
OMR_TRACKER_LATENCY=$(echo "$ret" | cut -d "/" -s -f5 | cut -d "." -f1 | tr -d '\n')
_update_rto "$OMR_TRACKER_LATENCY"
fi
return
@ -370,12 +368,24 @@ while true; do
else
OMR_TRACKER_LIST_HOSTS="$OMR_TRACKER_LIST_HOSTS,$OMR_TRACKER_HOST"
fi
OMR_TRACKER_STATUS_MSG="check error"
fi
else
OMR_TRACKER_STATUS_MSG=""
OMR_TRACKER_STATUS="OK"
break
fi
elif [ "$server_ping" != false ] && [ "$OMR_TRACKER_TYPE" != "httping" ] && [ "$OMR_TRACKER_SERVER_HTTP_TEST" = "1" ]; then
serverip_ping=false
config_load openmptcprouter
config_foreach _httping_server server $OMR_TRACKER_DEVICE_IP
if [ "$serverip_ping" = false ]; then
OMR_TRACKER_STATUS_MSG="No access to server API"
else
OMR_TRACKER_STATUS_MSG=""
OMR_TRACKER_STATUS="OK"
break
fi
else
OMR_TRACKER_STATUS_MSG=""
OMR_TRACKER_STATUS="OK"
@ -454,16 +464,28 @@ while true; do
break
else
if [ "$OMR_TRACKER_LIST_HOSTS6" = "" ]; then
OMR_TRACKER_LIST_HOSTS="$OMR_TRACKER_HOST6"
OMR_TRACKER_LIST_HOSTS6="$OMR_TRACKER_HOST6"
else
OMR_TRACKER_LIST_HOSTS6="$OMR_TRACKER_LIST_HOSTS6,$OMR_TRACKER_HOST6"
fi
OMR_TRACKER_STATUS_MSG="check error"
fi
else
OMR_TRACKER_STATUS_MSG=""
OMR_TRACKER_STATUS="OK"
break
fi
elif [ "$server_ping" != false ] && [ "$OMR_TRACKER_TYPE" != "httping" ] && [ "$OMR_TRACKER_SERVER_HTTP_TEST" = "1" ]; then
serverip_ping=false
config_load openmptcprouter
config_foreach _httping_server server $OMR_TRACKER_DEVICE_IP
if [ "$serverip_ping" = false ]; then
OMR_TRACKER_STATUS_MSG="No access to server API"
else
OMR_TRACKER_STATUS_MSG=""
OMR_TRACKER_STATUS="OK"
break
fi
else
OMR_TRACKER_STATUS_MSG=""
OMR_TRACKER_STATUS="OK"