1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-02-12 10:31:51 +00:00

Check in OMR-Tracker if server is reachable by a connection

This commit is contained in:
Ycarus (Yannick Chabanois) 2025-01-31 18:22:06 +01:00
parent d047067c1f
commit 26fdd7d28b

View file

@ -127,6 +127,23 @@ _ping_server() {
fi
}
_ping_server_all() {
count_server() {
config_get disabled $1 disabled
config_get serverip $1 ip
if [ "$disabled" != "1" ] && [ -n "$serverip" ]; then
servers=true
fi
}
config_load openmptcprouter
config_foreach count_server server
if [ "$server" = true ]; then
for intf in $(multipath 2>/dev/null | awk '/default/ { print $1 }); do
config_foreach _ping_server server $intf
done
fi
}
_httping_server() {
local servername="$1"
[ -z "$servername" ] && return
@ -150,6 +167,24 @@ _httping_server() {
fi
}
_httping_server_all() {
count_server() {
config_get disabled $1 disabled
config_get serverip $1 ip
if [ "$disabled" != "1" ] && [ -n "$serverip" ]; then
servers=true
fi
}
config_load openmptcprouter
config_foreach count_server server
if [ "ŝervers" = true ]; then
for intf in $(multipath 2>/dev/null | awk '/default/ { print $1 }); do
config_foreach _httping_server server $intf
done
fi
}
_ping() {
local host="$1"
[ -z "$host" ] && return
@ -445,7 +480,7 @@ while true; do
fi
[ -n "$(ip route show ${OMR_TRACKER_HOST} via ${OMR_TRACKER_DEVICE_GATEWAY} dev ${OMR_TRACKER_DEVICE} src ${OMR_TRACKER_DEVICE_IP})" ] && ip route del "$OMR_TRACKER_HOST" via "$OMR_TRACKER_DEVICE_GATEWAY" dev "$OMR_TRACKER_DEVICE" src "$OMR_TRACKER_DEVICE_IP" > /dev/null 2>&1
if $(exit $statusb); then
OMR_TRACKER_STATUS_MSG=""
#OMR_TRACKER_STATUS_MSG=""
OMR_TRACKER_STATUS="OK"
else
if [ "$OMR_TRACKER_LIST_HOSTS" = "" ]; then
@ -456,11 +491,11 @@ while true; do
OMR_TRACKER_STATUS_MSG="check error"
fi
else
OMR_TRACKER_STATUS_MSG=""
#OMR_TRACKER_STATUS_MSG=""
OMR_TRACKER_STATUS="OK"
fi
else
OMR_TRACKER_STATUS_MSG=""
#OMR_TRACKER_STATUS_MSG=""
OMR_TRACKER_STATUS="OK"
fi
if [ "$serverip_ping" != false ] && [ "$OMR_TRACKER_STATUS" = "OK" ] && [ "$OMR_TRACKER_TYPE" != "httping" ] && [ "$OMR_TRACKER_SERVER_HTTP_TEST" = "1" ]; then
@ -469,12 +504,24 @@ while true; do
config_foreach _httping_server server $OMR_TRACKER_DEVICE_IP
if [ "$serverip_ping" = false ]; then
#OMR_TRACKER_STATUS="ERROR"
OMR_TRACKER_STATUS_MSG="No access to server API"
OMR_TRACKER_STATUS_MSG="$OMR_TRACKER_STATUS_MSG No access to server API"
else
OMR_TRACKER_STATUS_MSG=""
OMR_TRACKER_STATUS="OK"
break
fi
elif [ "$serverip_ping" = false ] && [ "$OMR_TRACKER_STATUS" = "OK" ]; then
if [ "$OMR_TRACKER_TYPE" = "ping" ]; then
_ping_server_all
fi
if [ "$OMR_TRACKER_TYPE" = "httping" ]; then
_httping_server_all
fi
if [ "$server_ping" != false ] && [ "$servers" = true ]; then
OMR_TRACKER_STATUS_MSG="$OMR_TRACKER_STATUS_MSG No answer from server"
OMR_TRACKER_STATUS="ERROR"
break
fi
fi
[ "$OMR_TRACKER_STATUS" = "OK" ] && break
elif ! $(exit $status); then
@ -580,6 +627,18 @@ while true; do
OMR_TRACKER_STATUS="OK"
break
fi
elif [ "$serverip_ping" = false ] && [ "$OMR_TRACKER_STATUS" = "OK" ]; then
if [ "$OMR_TRACKER_TYPE" = "ping" ]; then
_ping_server_all
fi
if [ "$OMR_TRACKER_TYPE" = "httping" ]; then
_httping_server_all
fi
if [ "$server_ping" != false ] && [ "$servers" = true ]; then
OMR_TRACKER_STATUS_MSG="$OMR_TRACKER_STATUS_MSG No answer from server"
OMR_TRACKER_STATUS="ERROR"
break
fi
fi
[ "$OMR_TRACKER_STATUS" = "OK" ] && break
elif ! $(exit $status); then