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

Ping via interface instead of IP only

This commit is contained in:
Ycarus (Yannick Chabanois) 2019-09-06 18:11:30 +02:00
parent 403488eb53
commit 61bc8cf0b7
2 changed files with 10 additions and 10 deletions

View file

@ -985,13 +985,13 @@ function interfaces_status()
local latency = ""
local server_ping = ""
if connectivity ~= "ERROR" and ifname ~= "" and gateway ~= "" and gw_ping ~= "DOWN" and ifname ~= nil and mArray.openmptcprouter["service_addr"] ~= "" then
if connectivity ~= "ERROR" and ifname ~= "" and gateway ~= "" and gw_ping ~= "DOWN" and ifname ~= nil and mArray.openmptcprouter["service_addr"] ~= "" and ipaddr ~= "" then
local serverip = mArray.openmptcprouter["service_addr"]
if serverip == "127.0.0.1" then
serverip = mArray.openmptcprouter["wan_addr"]
end
if serverip ~= "" and uci:get("openmptcprouter", "settings", "disableserverping") ~= "1" then
local server_ping_test = sys.exec("ping -w 1 -c 1 -I " .. ifname .. " " .. serverip)
local server_ping_test = sys.exec("ping -B -w 1 -c 1 -I " .. ifname .. " " .. serverip)
local server_ping_result = ut.trim(sys.exec("echo '" .. server_ping_test .. "' | grep '100% packet loss'"))
if server_ping_result ~= "" then
server_ping = "DOWN"

View file

@ -77,9 +77,9 @@ _post_tracking() {
_ping_server() {
local serverip=$(uci -q get openmptcprouter.$1.ip)
local deviceip=$2
if [ -n "$serverip" ] && [ -n "$deviceip" ]; then
_ping $serverip $deviceip "yes"
local device=$2
if [ -n "$serverip" ] && [ -n "$device" ]; then
_ping $serverip $device "yes"
statusp=$?
if $(exit $statusp); then
serverip_ping=true
@ -91,9 +91,9 @@ _ping_server() {
_ping() {
local host=$1
local deviceip=$2
local device=$2
local localip=$3
ret=$(ping -I "${deviceip}" \
ret=$(ping -B -I "${device}" \
-w "$OMR_TRACKER_TIMEOUT" \
-c 1 \
-q \
@ -200,7 +200,7 @@ while true; do
tries="$OMR_TRACKER_TRIES"
# loop until tries attempts have been reached
while [ "$tries" -gt 0 ]; do
_ping "$OMR_TRACKER_DEVICE_GATEWAY" "$OMR_TRACKER_DEVICE_IP" "no"
_ping "$OMR_TRACKER_DEVICE_GATEWAY" "$OMR_TRACKER_DEVICE" "no"
status=$?
if $(exit $status) && [ "$OMR_TRACKER_TYPE" = "none" ]; then
OMR_TRACKER_STATUS_MSG=""
@ -213,7 +213,7 @@ while true; do
serverip_ping=false
if [ "$OMR_TRACKER_TYPE" = "ping" ]; then
config_load openmptcprouter
config_foreach _ping_server server $OMR_TRACKER_DEVICE_IP
config_foreach _ping_server server $OMR_TRACKER_DEVICE
fi
if [ "$serverip_ping" = false ]; then
# Check if route is not used
@ -225,7 +225,7 @@ while true; do
_restart
done
if [ "$OMR_TRACKER_TYPE" = "ping" ]; then
_ping "$OMR_TRACKER_HOST" "$OMR_TRACKER_DEVICE_IP" "yes"
_ping "$OMR_TRACKER_HOST" "$OMR_TRACKER_DEVICE" "yes"
statusb=$?
elif [ "$OMR_TRACKER_TYPE" = "httping" ]; then
_httping "$OMR_TRACKER_HOST" "$OMR_TRACKER_DEVICE_IP" "yes"