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())
66 netmask = v:netmask(),
68 expires = v:expires(),
74 mac = dev and dev:mac(),
75 type = dev and dev:type(),
76 name = dev and dev:get_i18n(),
77 ether = link and link.type == 1
80 rv.wan[#rv.wan+1] = wan_info
84 if #wan6_nets > 0 then
89 for k, v in pairs(wan6_nets) do
90 local dev = v:get_interface()
91 local link = dev and ipc.link(dev:name())
93 ip6addr = v:ip6addr(),
94 gw6addr = v:gw6addr(),
96 ip6prefix = v:ip6prefix(),
101 link = v:adminlink(),
102 mac = dev and dev:mac(),
103 type = dev and dev:type(),
104 name = dev and dev:get_i18n(),
105 ether = link and link.type == 1
108 rv.wan6[#rv.wan6+1] = wan6_info
113 local dsl_stat = luci.sys.exec("/etc/init.d/dsl_control lucistat")
114 local dsl_func = loadstring(dsl_stat)
120 luci.http.prepare_content("application/json")
121 luci.http.write_json(rv)
129 <h2 name="content"><%:Status%></h2>
132 local incdir = util.libpath() .. "/view/admin_status/index/"
133 if fs.access(incdir) then
136 for inc in fs.dir(incdir) do
137 if inc:match("%.htm$") then
138 includes[#includes + 1] = inc:gsub("%.htm$", "")
141 for _, inc in luci.util.vspairs(includes) do
142 include("admin_status/index/" .. inc)
147 <script type="text/javascript" src="<%=resource%>/view/status/index.js"></script>