mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-03-09 15:40:03 +00:00
Add MPTCP bandwidth graph
This commit is contained in:
parent
f358d8f929
commit
8b4c845a9e
3 changed files with 1264 additions and 3 deletions
|
@ -1,7 +1,46 @@
|
|||
-- Copyright 2008 Steven Barth <steven@midlink.org>
|
||||
-- Copyright 2011 Jo-Philipp Wich <jow@openwrt.org>
|
||||
-- Copyright 2018 Ycarus (Yannick Chabanois) <ycarus@zugaina.org>
|
||||
-- Licensed to the public under the Apache License 2.0.
|
||||
|
||||
module("luci.controller.mptcp", package.seeall)
|
||||
|
||||
function index()
|
||||
entry(
|
||||
{"admin", "network", "mptcp"},
|
||||
cbi("mptcp"), _("MPTCP"), 55)
|
||||
entry({"admin", "network", "mptcp"}, alias("admin", "network", "mptcp", "settings"), _("MPTCP"))
|
||||
entry({"admin", "network", "mptcp", "settings"}, cbi("mptcp"), _("Settings"),2)
|
||||
entry({"admin", "network", "mptcp", "bandwidth"}, template("multipath"), _("Bandwidth"), 3).leaf = true
|
||||
entry({"admin", "network", "mptcp", "multipath_bandwidth"}, call("multipath_bandwidth")).leaf = true
|
||||
entry({"admin", "network", "mptcp", "interface_bandwidth"}, call("interface_bandwidth")).leaf = true
|
||||
end
|
||||
|
||||
function interface_bandwidth(iface)
|
||||
luci.http.prepare_content("application/json")
|
||||
local bwc = io.popen("luci-bwc -i %q 2>/dev/null" % iface)
|
||||
if bwc then
|
||||
luci.http.write("[")
|
||||
while true do
|
||||
local ln = bwc:read("*l")
|
||||
if not ln then break end
|
||||
luci.http.write(ln)
|
||||
end
|
||||
luci.http.write("]")
|
||||
bwc:close()
|
||||
end
|
||||
end
|
||||
|
||||
function multipath_bandwidth()
|
||||
local result = { };
|
||||
local uci = luci.model.uci.cursor()
|
||||
|
||||
for _, dev in luci.util.vspairs(luci.sys.net.devices()) do
|
||||
if dev ~= "lo" then
|
||||
local multipath = uci:get("network", dev, "multipath")
|
||||
if multipath == "on" or multipath == "master" or multipath == "backup" or multipath == "handover" then
|
||||
result[dev] = "[" .. string.gsub((luci.sys.exec("luci-bwc -i %q 2>/dev/null" % dev)), '[\r\n]', '') .. "]"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(result)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue