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:
parent
57934483b7
commit
27979c78d3
8 changed files with 125 additions and 12 deletions
|
@ -240,7 +240,17 @@
|
|||
<input type="checkbox" name="disablegwping" class="cbi-input-checkbox" value="1" <% if luci.model.uci.cursor():get("openmptcprouter","settings","disablegwping") == "1" then %>checked<% end %>>
|
||||
<br />
|
||||
<div class="cbi-value-description">
|
||||
<%:Disable gateway ping status check%>
|
||||
<%:Disable gateway ping check in status page%>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cbi-value">
|
||||
<label class="cbi-value-title"><%:Disable server http test%></label>
|
||||
<div class="cbi-value-field">
|
||||
<input type="checkbox" name="disableserverhttptest" class="cbi-input-checkbox" value="1" <% if luci.model.uci.cursor():get("openmptcprouter","settings","disableserverhttptest") == "1" then %>checked<% end %>>
|
||||
<br />
|
||||
<div class="cbi-value-description">
|
||||
<%:Disable HTTP test on Server API in status page%>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -452,6 +452,7 @@ local statuslogo = ucic:get("openmptcprouter","settings","statuslogo") or "openm
|
|||
var gw_ping = mArray.wans[i].gw_ping;
|
||||
var gw_ping6 = mArray.wans[i].gw_ping6;
|
||||
var server_ping = mArray.wans[i].server_ping;
|
||||
var server_http = mArray.wans[i].server_http;
|
||||
var ipv6_discover = mArray.wans[i].ipv6_discover;
|
||||
var multipath_available = mArray.wans[i].multipath_available;
|
||||
var multipath_state = mArray.wans[i].multipath_state;
|
||||
|
@ -563,6 +564,10 @@ local statuslogo = ucic:get("openmptcprouter","settings","statuslogo") or "openm
|
|||
{
|
||||
statusMessage += '<%:No Server ping response after 1 second%>' + '<br />';
|
||||
}
|
||||
if(server_http == 'DOWN' && mArray.openmptcprouter.service_addr !== "")
|
||||
{
|
||||
statusMessage += '<%:No Server http response after 1 second%>' + '<br />';
|
||||
}
|
||||
if (stat == 'Offline' && ipaddr != '' && ipaddr == mArray.wans[i].gateway)
|
||||
{
|
||||
statusMessage += '<%:Wan IP and gateway are identical%>' + '<br />';
|
||||
|
|
|
@ -836,6 +836,7 @@ function interfaces_status()
|
|||
|
||||
mArray.openmptcprouter["vps_hostname"] = "Server"
|
||||
-- Get VPS info
|
||||
local adminport = ""
|
||||
ucic:foreach("openmptcprouter", "server", function(s)
|
||||
local serverips = uci:get("openmptcprouter",s[".name"],"ip") or { "" }
|
||||
local master = uci:get("openmptcprouter",s[".name"],"master") or "1"
|
||||
|
@ -849,7 +850,7 @@ function interfaces_status()
|
|||
if uci:get("openmptcprouter",s[".name"],"admin_error") == "1" then
|
||||
mArray.openmptcprouter["vps_admin_error"] = true
|
||||
end
|
||||
local adminport = uci:get("openmptcprouter",s[".name"],"port") or "65500"
|
||||
adminport = uci:get("openmptcprouter",s[".name"],"port") or "65500"
|
||||
local token = uci:get("openmptcprouter",s[".name"],"token") or ""
|
||||
if token ~= "" then
|
||||
local vpsinfo_json = ""
|
||||
|
@ -1120,6 +1121,7 @@ function interfaces_status()
|
|||
local ipv6 = section["ipv6"] or "0"
|
||||
local mac = section ["macaddr"] or ""
|
||||
local itype = section ["type"] or ""
|
||||
local state = section ["state"] or ""
|
||||
|
||||
--if not ipaddr or not gateway then return end
|
||||
-- Don't show if0 in the overview
|
||||
|
@ -1325,6 +1327,7 @@ function interfaces_status()
|
|||
|
||||
local latency = ""
|
||||
local server_ping = ""
|
||||
local server_http = ""
|
||||
--if connectivity ~= "ERROR" and ifname ~= "" and gateway ~= "" and gw_ping ~= "DOWN" and ifname ~= nil and mArray.openmptcprouter["service_addr"] ~= "" and ipaddr ~= "" then
|
||||
if ifname ~= "" and (gateway ~= "" or gateway6 ~= "") and gw_ping ~= "DOWN" and ifname ~= nil and mArray.openmptcprouter["service_addr"] ~= "" and (ipaddr ~= "" or ip6addr ~= "") and connectivity ~= "ERROR" then
|
||||
local serverip = mArray.openmptcprouter["service_addr"]
|
||||
|
@ -1345,6 +1348,40 @@ function interfaces_status()
|
|||
latency = ut.trim(sys.exec("echo '" .. server_ping_test .. "' | cut -d '/' -s -f5 | cut -d '.' -f1"))
|
||||
end
|
||||
end
|
||||
|
||||
if adminport == "" then
|
||||
adminport = "65500"
|
||||
end
|
||||
if server_ping == "UP" and uci:get("openmptcprouter", "settings", "disableserverhttptest") ~= "1" and ipaddr ~= "" and adminport ~= "" then
|
||||
local server_http_result = ""
|
||||
local server_http_test = ""
|
||||
if mArray.openmptcprouter["service_addr_ip"] ~= "" then
|
||||
server_http_test = sys.exec("httping -l " .. mArray.openmptcprouter["service_addr_ip"] .. ":" .. adminport .. " -y " .. ipaddr .. " -t 1 -c 1")
|
||||
server_http_result = ut.trim(sys.exec("echo '" .. server_http_test .. "' | grep '100.00% failed'"))
|
||||
if server_http_result ~= "" then
|
||||
server_http = "DOWN"
|
||||
if connectivity == "OK" then
|
||||
connectivity = "WARNING"
|
||||
end
|
||||
end
|
||||
end
|
||||
if mArray.openmptcprouter["service_addr_ip6"] ~= "" then
|
||||
server_http_test = sys.exec("httping -l [" .. mArray.openmptcprouter["service_addr_ip6"] .. "]:" .. adminport .. " -y " .. ipaddr .. " -t 1 -c 1")
|
||||
server_http_result = ut.trim(sys.exec("echo '" .. server_http_test .. "' | grep '100.00% failed'"))
|
||||
if server_http_result ~= "" then
|
||||
server_http = "DOWN"
|
||||
if connectivity == "OK" then
|
||||
connectivity = "WARNING"
|
||||
end
|
||||
end
|
||||
end
|
||||
if server_http_result ~= "" then
|
||||
server_http = "DOWN"
|
||||
if connectivity == "OK" then
|
||||
connectivity = "WARNING"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local multipath_available = ""
|
||||
|
@ -1443,6 +1480,11 @@ function interfaces_status()
|
|||
rx = ut.trim(sys.exec("devstatus " .. ifname .. " | jsonfilter -e '@.statistics.rx_bytes'"))
|
||||
tx = ut.trim(sys.exec("devstatus " .. ifname .. " | jsonfilter -e '@.statistics.tx_bytes'"))
|
||||
end
|
||||
|
||||
if state == "down" then
|
||||
connectivity = "ERROR"
|
||||
end
|
||||
|
||||
local data = {
|
||||
label = section["label"] or interface,
|
||||
name = interface,
|
||||
|
@ -1466,6 +1508,7 @@ function interfaces_status()
|
|||
gw_ping = gw_ping,
|
||||
gw_ping6 = gw_ping6,
|
||||
server_ping = server_ping,
|
||||
server_http = server_http,
|
||||
ipv6_discover = ipv6_discover,
|
||||
multipath_available = multipath_available,
|
||||
multipath_state = current_multipath_state,
|
||||
|
@ -1481,6 +1524,7 @@ function interfaces_status()
|
|||
tx = tx,
|
||||
zonewan = zonewan,
|
||||
iftype = itype,
|
||||
state = state,
|
||||
}
|
||||
if ifname ~= nil and ifname:match("^tun.*") then
|
||||
table.insert(mArray.tunnels, data);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue