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

Test if wan gateway is up or down in status page

This commit is contained in:
Ycarus 2018-05-03 10:51:04 +02:00
parent 59d6990dd3
commit 8d1124f3b1
2 changed files with 23 additions and 5 deletions

View file

@ -243,7 +243,7 @@ function interfaces_status()
local interface = section[".name"]
local net = ntm:get_network(interface)
local ipaddr = net:ipaddr()
local gateway = section['gateway']
local gateway = section['gateway'] or ""
local multipath = section['multipath']
--if not ipaddr or not gateway then return end
@ -263,6 +263,16 @@ function interfaces_status()
connectivity = 'ERROR'
end
local gw_ping
if gateway ~= "" then
local gw_ping_test = ut.trim(sys.exec("ping -W 1 -c 1 " .. gateway .. " | grep '100% packet loss'"))
if gw_ping_test == "" then
gw_ping = 'UP'
else
gw_ping = 'DOWN'
end
end
local publicIP = "-"
local latency = "-"
@ -282,6 +292,7 @@ function interfaces_status()
qos = section['trafficcontrol'],
download = section['download'],
upload = section['upload'],
gw_ping = gw_ping,
}
if ifname:match("^tun.*") then