2 Copyright
2008 Steven Barth
<steven@midlink.org
>
3 Copyright
2008-
2018 Jo-Philipp Wich
<jo@mein.io
>
4 Licensed to the public under the Apache License
2.0.
8 local fs = require
"nixio.fs"
9 local ipc = require
"luci.ip"
10 local util = require
"luci.util"
11 local stat = require
"luci.tools.status"
12 local ver = require
"luci.version"
14 if luci.http.formvalue(
"status") ==
"1" then
16 local sysinfo = luci.util.ubus(
"system",
"info") or { }
18 local meminfo = sysinfo.memory or {
25 local swapinfo = sysinfo.swap or {
30 local has_dsl = fs.access(
"/etc/init.d/dsl_control")
32 local ntm = require
"luci.model.network".init()
33 local wan_nets = ntm:get_wan_networks()
34 local wan6_nets = ntm:get_wan6_networks()
36 local conn_count = tonumber(
37 fs.readfile(
"/proc/sys/net/netfilter/nf_conntrack_count") or
"") or
0
39 local conn_max = tonumber(luci.sys.exec(
40 "sysctl -n -e net.nf_conntrack_max net.ipv4.netfilter.ip_conntrack_max"
41 ):match(
"%d+")) or
4096
44 uptime = sysinfo.uptime or
0,
45 localtime = os.date(),
46 loadavg = sysinfo.load or {
0,
0,
0 },
50 conncount = conn_count,
51 wifinets = stat.wifi_networks()
59 for k, v in pairs(wan_nets) do
60 local dev = v:get_interface()
61 local link = dev and ipc.link(dev:name())
64 ipaddrs = v:ipaddrs(),
67 expires = v:expires(),
73 mac = dev and dev:mac(),
74 type = dev and dev:type(),
75 name = dev and dev:get_i18n(),
76 ether = link and link.type ==
1
79 rv.wan[#rv.wan+
1] = wan_info
83 if #wan6_nets
> 0 then
88 for k, v in pairs(wan6_nets) do
89 local dev = v:get_interface()
90 local link = dev and ipc.link(dev:name())
92 ip6addrs = v:ip6addrs(),
93 gw6addr = v:gw6addr(),
95 ip6prefix = v:ip6prefix(),
100 link = v:adminlink(),
101 mac = dev and dev:mac(),
102 type = dev and dev:type(),
103 name = dev and dev:get_i18n(),
104 ether = link and link.type ==
1
107 rv.wan6[#rv.wan6+
1] = wan6_info
112 local dsl_stat = luci.sys.exec(
"/etc/init.d/dsl_control lucistat")
113 local dsl_func = loadstring(dsl_stat)
119 luci.http.prepare_content(
"application/json")
120 luci.http.write_json(rv)
128 <h2 name=
"content"><%:Status%
></h2>
131 local incdir = util.libpath() ..
"/view/admin_status/index/"
132 if fs.access(incdir) then
135 for inc in fs.dir(incdir) do
136 if inc:match(
"%.htm$") then
137 includes[#includes +
1] = inc:gsub(
"%.htm$",
"")
140 for _, inc in luci.util.vspairs(includes) do
141 include(
"admin_status/index/" .. inc)
146 <script type=
"text/javascript" src=
"<%=resource%>/view/status/index.js"></script>