1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-02-14 19:41:51 +00:00

Fix MPTCP bandwidth graph in some case

This commit is contained in:
Ycarus (Yannick Chabanois) 2019-11-18 21:21:54 +01:00
parent 1400f7b0aa
commit 495d658f29
2 changed files with 26 additions and 7 deletions

View file

@ -40,6 +40,9 @@ function multipath_bandwidth()
uci:foreach("network", "interface", function(s) uci:foreach("network", "interface", function(s)
local dev = s["ifname"] or "" local dev = s["ifname"] or ""
if dev == "" then
dev = get_device(s["ifname"])
end
if dev ~= "lo" and dev ~= "" then if dev ~= "lo" and dev ~= "" then
local multipath = s["multipath"] or "off" local multipath = s["multipath"] or "off"
if multipath == "on" or multipath == "master" or multipath == "backup" or multipath == "handover" then if multipath == "on" or multipath == "master" or multipath == "backup" or multipath == "handover" then
@ -59,7 +62,11 @@ end
function get_device(interface) function get_device(interface)
local dump = require("luci.util").ubus("network.interface.%s" % interface, "status", {}) local dump = require("luci.util").ubus("network.interface.%s" % interface, "status", {})
return dump['l3_device'] if dump then
return dump['l3_device']
else
return ""
end
end end
function mptcp_check_trace(iface) function mptcp_check_trace(iface)

View file

@ -24,6 +24,15 @@
local ntm = require "luci.model.network".init() local ntm = require "luci.model.network".init()
local uci = require "luci.model.uci".cursor() local uci = require "luci.model.uci".cursor()
function get_device(interface)
local dump = require("luci.util").ubus("network.interface.%s" % interface, "status", {})
if dump and dump['l3_device'] ~= "" then
return dump['l3_device']
else
return interface
end
end
local dev local dev
local devices = { "all" } local devices = { "all" }
for _, dev in ipairs(ntm:get_networks()) do for _, dev in ipairs(ntm:get_networks()) do
@ -35,7 +44,7 @@
--end --end
end end
local curdev = luci.http.formvalue("dev") or "all" local curifname = luci.http.formvalue("dev") or "all"
-%> -%>
<%+header%> <%+header%>
@ -96,7 +105,7 @@
); );
} }
<% if curdev == "all" then %> <% if curifname == "all" then %>
var all = true; var all = true;
var bwxhr = new XHR(); var bwxhr = new XHR();
@ -652,7 +661,7 @@
label_scale.innerHTML = String.format('<%:(%d minute window, %d second interval)%>', data_wanted / 60, 3); label_scale.innerHTML = String.format('<%:(%d minute window, %d second interval)%>', data_wanted / 60, 3);
/* render datasets, start update interval */ /* render datasets, start update interval */
XHR.poll(3, '<%=build_url("admin/network/mptcp/interface_bandwidth", curdev)%>', null, XHR.poll(3, '<%=build_url("admin/network/mptcp/interface_bandwidth", curifname)%>', null,
function(x, data) function(x, data)
{ {
var data_max = 0; var data_max = 0;
@ -762,12 +771,15 @@
<h2><a id="content" name="content"><%:Realtime Traffic%></a></h2> <h2><a id="content" name="content"><%:Realtime Traffic%></a></h2>
<ul class="cbi-tabmenu"> <ul class="cbi-tabmenu">
<% for _, dev in ipairs(devices) do %> <% for _, dev in ipairs(devices) do
<li class="cbi-tab<%= dev == curdev and "" or "-disabled" %>"><a href="?dev=<%=pcdata(dev)%>"><%=pcdata(dev)%></a></li> local ifname = get_device(dev)
%>
<li class="cbi-tab<%= ifname == curifname and "" or "-disabled" %>"><a href="?dev=<%=pcdata(get_device(dev))%>"><%=pcdata(dev)%></a></li>
<% end %> <% end %>
</ul> </ul>
<% if curdev == "all" then %> <% if curifname == "all" then %>
<strong><%:Download:%></strong> <strong><%:Download:%></strong>
<embed id="dnsvg" style="width:100%; height:300px; border:1px solid #000000; background-color:#FFFFFF" src="<%=resource%>/bandwidth.svg" /> <embed id="dnsvg" style="width:100%; height:300px; border:1px solid #000000; background-color:#FFFFFF" src="<%=resource%>/bandwidth.svg" />