2008-07-07 22:00:56 +00:00
|
|
|
<%#
|
2015-01-16 22:38:38 +00:00
|
|
|
Copyright 2008 Steven Barth <steven@midlink.org>
|
2018-11-21 19:16:06 +00:00
|
|
|
Copyright 2008-2018 Jo-Philipp Wich <jo@mein.io>
|
2015-01-16 22:38:38 +00:00
|
|
|
Licensed to the public under the Apache License 2.0.
|
2008-07-07 22:00:56 +00:00
|
|
|
-%>
|
2011-02-11 05:01:18 +00:00
|
|
|
|
|
|
|
<%
|
2015-01-15 14:37:46 +00:00
|
|
|
local fs = require "nixio.fs"
|
2018-05-30 12:50:14 +00:00
|
|
|
local ipc = require "luci.ip"
|
2015-01-15 14:37:46 +00:00
|
|
|
local util = require "luci.util"
|
|
|
|
local stat = require "luci.tools.status"
|
2015-01-16 20:39:26 +00:00
|
|
|
local ver = require "luci.version"
|
2011-03-13 13:57:21 +00:00
|
|
|
|
2018-12-10 16:56:42 +00:00
|
|
|
if luci.http.formvalue("status") == "1" then
|
2015-01-15 12:35:10 +00:00
|
|
|
|
2018-12-10 16:56:42 +00:00
|
|
|
local sysinfo = luci.util.ubus("system", "info") or { }
|
2015-01-15 12:35:10 +00:00
|
|
|
|
2018-12-10 16:56:42 +00:00
|
|
|
local meminfo = sysinfo.memory or {
|
|
|
|
total = 0,
|
|
|
|
free = 0,
|
|
|
|
buffered = 0,
|
|
|
|
shared = 0
|
|
|
|
}
|
2015-01-15 12:35:10 +00:00
|
|
|
|
2018-12-10 16:56:42 +00:00
|
|
|
local swapinfo = sysinfo.swap or {
|
|
|
|
total = 0,
|
|
|
|
free = 0
|
|
|
|
}
|
2015-01-15 12:35:10 +00:00
|
|
|
|
2018-12-10 16:56:42 +00:00
|
|
|
local has_dsl = fs.access("/etc/init.d/dsl_control")
|
2011-03-13 13:57:21 +00:00
|
|
|
|
2011-02-11 05:01:18 +00:00
|
|
|
local ntm = require "luci.model.network".init()
|
luci-base: Show multiple upstream interface
Several devices have multiple upstream interfaces, for example a fixed
and a mobile broadband connection. Currently, only one upstream
interface is shown per address family in Luci. So in my example, one of
the interfaces would not appear on the Status-page.
This PR introduces support for showing multiple upstream interfaces on
the Status-page. The code is not very complicated. get_status_by_route()
has been extended to return a list of all routes, and
get_wannet()/get_wan6net() now returns all upstream interfaces.
I could not find any other (active) users of these three functions than
calls triggered from the Status-page, so changing the default behavior
should be fine. get_wandev()/get_wan6dev() called get_status_by_route(),
but I could not find any place where those functions were called. I
removed the dev-functions instead of keeping the old
get_status_by_route().
On the status page, the wan/wan6-variables have been replaced with
arrays. When populating the html, we now iterate through these arrays
and create one element for each interface.
I have tested the code with different interface types, v4, v6, as well as
disconnecting and connecting interfaces. The status is updated and the
correct interfaces (or sometimes none at all) are shown.
Signed-off-by: Kristian Evensen <kristian.evensen@gmail.com>
2018-09-09 15:27:28 +00:00
|
|
|
local wan_nets = ntm:get_wan_networks()
|
|
|
|
local wan6_nets = ntm:get_wan6_networks()
|
2011-02-11 05:01:18 +00:00
|
|
|
|
2017-04-20 14:55:29 +00:00
|
|
|
local conn_count = tonumber(
|
2017-12-04 13:44:00 +00:00
|
|
|
fs.readfile("/proc/sys/net/netfilter/nf_conntrack_count") or "") or 0
|
2011-02-11 05:01:18 +00:00
|
|
|
|
2018-02-04 18:19:44 +00:00
|
|
|
local conn_max = tonumber(luci.sys.exec(
|
|
|
|
"sysctl -n -e net.nf_conntrack_max net.ipv4.netfilter.ip_conntrack_max"
|
|
|
|
):match("%d+")) or 4096
|
2011-02-11 05:01:18 +00:00
|
|
|
|
|
|
|
local rv = {
|
2015-01-15 12:35:10 +00:00
|
|
|
uptime = sysinfo.uptime or 0,
|
2015-01-15 16:41:26 +00:00
|
|
|
localtime = os.date(),
|
2015-01-15 12:35:10 +00:00
|
|
|
loadavg = sysinfo.load or { 0, 0, 0 },
|
|
|
|
memory = meminfo,
|
|
|
|
swap = swapinfo,
|
2011-02-11 05:01:18 +00:00
|
|
|
connmax = conn_max,
|
2011-03-13 13:57:21 +00:00
|
|
|
conncount = conn_count,
|
2015-01-15 14:37:46 +00:00
|
|
|
wifinets = stat.wifi_networks()
|
2011-02-11 05:01:18 +00:00
|
|
|
}
|
|
|
|
|
luci-base: Show multiple upstream interface
Several devices have multiple upstream interfaces, for example a fixed
and a mobile broadband connection. Currently, only one upstream
interface is shown per address family in Luci. So in my example, one of
the interfaces would not appear on the Status-page.
This PR introduces support for showing multiple upstream interfaces on
the Status-page. The code is not very complicated. get_status_by_route()
has been extended to return a list of all routes, and
get_wannet()/get_wan6net() now returns all upstream interfaces.
I could not find any other (active) users of these three functions than
calls triggered from the Status-page, so changing the default behavior
should be fine. get_wandev()/get_wan6dev() called get_status_by_route(),
but I could not find any place where those functions were called. I
removed the dev-functions instead of keeping the old
get_status_by_route().
On the status page, the wan/wan6-variables have been replaced with
arrays. When populating the html, we now iterate through these arrays
and create one element for each interface.
I have tested the code with different interface types, v4, v6, as well as
disconnecting and connecting interfaces. The status is updated and the
correct interfaces (or sometimes none at all) are shown.
Signed-off-by: Kristian Evensen <kristian.evensen@gmail.com>
2018-09-09 15:27:28 +00:00
|
|
|
if #wan_nets > 0 then
|
|
|
|
local k, v
|
|
|
|
|
|
|
|
rv.wan = { }
|
|
|
|
|
|
|
|
for k, v in pairs(wan_nets) do
|
|
|
|
local dev = v:get_interface()
|
|
|
|
local link = dev and ipc.link(dev:name())
|
|
|
|
|
|
|
|
local wan_info = {
|
|
|
|
ipaddr = v:ipaddr(),
|
|
|
|
gwaddr = v:gwaddr(),
|
|
|
|
netmask = v:netmask(),
|
|
|
|
dns = v:dnsaddrs(),
|
|
|
|
expires = v:expires(),
|
|
|
|
uptime = v:uptime(),
|
|
|
|
proto = v:proto(),
|
|
|
|
i18n = v:get_i18n(),
|
|
|
|
ifname = v:ifname(),
|
|
|
|
link = v:adminlink(),
|
|
|
|
mac = dev and dev:mac(),
|
|
|
|
type = dev and dev:type(),
|
|
|
|
name = dev and dev:get_i18n(),
|
|
|
|
ether = link and link.type == 1
|
|
|
|
}
|
|
|
|
|
|
|
|
rv.wan[#rv.wan+1] = wan_info
|
|
|
|
end
|
2011-02-11 05:01:18 +00:00
|
|
|
end
|
|
|
|
|
luci-base: Show multiple upstream interface
Several devices have multiple upstream interfaces, for example a fixed
and a mobile broadband connection. Currently, only one upstream
interface is shown per address family in Luci. So in my example, one of
the interfaces would not appear on the Status-page.
This PR introduces support for showing multiple upstream interfaces on
the Status-page. The code is not very complicated. get_status_by_route()
has been extended to return a list of all routes, and
get_wannet()/get_wan6net() now returns all upstream interfaces.
I could not find any other (active) users of these three functions than
calls triggered from the Status-page, so changing the default behavior
should be fine. get_wandev()/get_wan6dev() called get_status_by_route(),
but I could not find any place where those functions were called. I
removed the dev-functions instead of keeping the old
get_status_by_route().
On the status page, the wan/wan6-variables have been replaced with
arrays. When populating the html, we now iterate through these arrays
and create one element for each interface.
I have tested the code with different interface types, v4, v6, as well as
disconnecting and connecting interfaces. The status is updated and the
correct interfaces (or sometimes none at all) are shown.
Signed-off-by: Kristian Evensen <kristian.evensen@gmail.com>
2018-09-09 15:27:28 +00:00
|
|
|
if #wan6_nets > 0 then
|
|
|
|
local k, v
|
|
|
|
|
|
|
|
rv.wan6 = { }
|
|
|
|
|
|
|
|
for k, v in pairs(wan6_nets) do
|
|
|
|
local dev = v:get_interface()
|
|
|
|
local link = dev and ipc.link(dev:name())
|
|
|
|
local wan6_info = {
|
|
|
|
ip6addr = v:ip6addr(),
|
|
|
|
gw6addr = v:gw6addr(),
|
|
|
|
dns = v:dns6addrs(),
|
|
|
|
ip6prefix = v:ip6prefix(),
|
|
|
|
uptime = v:uptime(),
|
|
|
|
proto = v:proto(),
|
|
|
|
i18n = v:get_i18n(),
|
|
|
|
ifname = v:ifname(),
|
|
|
|
link = v:adminlink(),
|
|
|
|
mac = dev and dev:mac(),
|
|
|
|
type = dev and dev:type(),
|
|
|
|
name = dev and dev:get_i18n(),
|
|
|
|
ether = link and link.type == 1
|
|
|
|
}
|
|
|
|
|
|
|
|
rv.wan6[#rv.wan6+1] = wan6_info
|
|
|
|
end
|
2011-02-11 05:01:18 +00:00
|
|
|
end
|
|
|
|
|
2013-10-09 11:17:55 +00:00
|
|
|
if has_dsl then
|
|
|
|
local dsl_stat = luci.sys.exec("/etc/init.d/dsl_control lucistat")
|
|
|
|
local dsl_func = loadstring(dsl_stat)
|
2015-10-03 14:11:11 +00:00
|
|
|
if dsl_func then
|
|
|
|
rv.dsl = dsl_func()
|
|
|
|
end
|
2013-10-09 11:17:55 +00:00
|
|
|
end
|
|
|
|
|
2011-02-11 05:01:18 +00:00
|
|
|
luci.http.prepare_content("application/json")
|
|
|
|
luci.http.write_json(rv)
|
|
|
|
|
|
|
|
return
|
|
|
|
end
|
|
|
|
-%>
|
|
|
|
|
2008-05-13 17:32:11 +00:00
|
|
|
<%+header%>
|
2011-02-11 05:01:18 +00:00
|
|
|
|
2015-10-06 11:29:43 +00:00
|
|
|
<h2 name="content"><%:Status%></h2>
|
2011-02-11 05:01:18 +00:00
|
|
|
|
2011-05-04 21:04:31 +00:00
|
|
|
<%-
|
2015-01-15 14:37:46 +00:00
|
|
|
local incdir = util.libpath() .. "/view/admin_status/index/"
|
|
|
|
if fs.access(incdir) then
|
2018-12-10 16:56:42 +00:00
|
|
|
local _, inc
|
|
|
|
local includes = {}
|
2015-01-15 14:37:46 +00:00
|
|
|
for inc in fs.dir(incdir) do
|
2011-05-04 21:04:31 +00:00
|
|
|
if inc:match("%.htm$") then
|
2018-12-10 16:56:42 +00:00
|
|
|
includes[#includes + 1] = inc:gsub("%.htm$", "")
|
2011-05-04 21:04:31 +00:00
|
|
|
end
|
|
|
|
end
|
2018-12-10 16:56:42 +00:00
|
|
|
for _, inc in luci.util.vspairs(includes) do
|
|
|
|
include("admin_status/index/" .. inc)
|
|
|
|
end
|
2011-05-04 21:04:31 +00:00
|
|
|
end
|
|
|
|
-%>
|
|
|
|
|
2018-11-21 19:16:06 +00:00
|
|
|
<script type="text/javascript" src="<%=resource%>/view/status/index.js"></script>
|
|
|
|
|
2011-02-11 05:01:18 +00:00
|
|
|
<%+footer%>
|