1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
|
<%#
Copyright 2008 Steven Barth <steven@midlink.org>
Copyright 2008-2018 Jo-Philipp Wich <jo@mein.io>
Licensed to the public under the Apache License 2.0.
-%>
<%
local fs = require "nixio.fs"
local ipc = require "luci.ip"
local util = require "luci.util"
local stat = require "luci.tools.status"
local ver = require "luci.version"
local has_ipv6 = fs.access("/proc/net/ipv6_route")
local has_dhcp = fs.access("/etc/config/dhcp")
local has_wifi = ((fs.stat("/etc/config/wireless", "size") or 0) > 0)
local sysinfo = luci.util.ubus("system", "info") or { }
local boardinfo = luci.util.ubus("system", "board") or { }
local unameinfo = nixio.uname() or { }
local meminfo = sysinfo.memory or {
total = 0,
free = 0,
buffered = 0,
shared = 0
}
local swapinfo = sysinfo.swap or {
total = 0,
free = 0
}
local has_dsl = fs.access("/etc/init.d/dsl_control")
if luci.http.formvalue("status") == "1" then
local ntm = require "luci.model.network".init()
local wan_nets = ntm:get_wan_networks()
local wan6_nets = ntm:get_wan6_networks()
local conn_count = tonumber(
fs.readfile("/proc/sys/net/netfilter/nf_conntrack_count") or "") or 0
local conn_max = tonumber(luci.sys.exec(
"sysctl -n -e net.nf_conntrack_max net.ipv4.netfilter.ip_conntrack_max"
):match("%d+")) or 4096
local rv = {
uptime = sysinfo.uptime or 0,
localtime = os.date(),
loadavg = sysinfo.load or { 0, 0, 0 },
memory = meminfo,
swap = swapinfo,
connmax = conn_max,
conncount = conn_count,
wifinets = stat.wifi_networks()
}
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
end
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
end
if has_dsl then
local dsl_stat = luci.sys.exec("/etc/init.d/dsl_control lucistat")
local dsl_func = loadstring(dsl_stat)
if dsl_func then
rv.dsl = dsl_func()
end
end
luci.http.prepare_content("application/json")
luci.http.write_json(rv)
return
end
-%>
<%+header%>
<h2 name="content"><%:Status%></h2>
<div class="cbi-section">
<h3><%:System%></h3>
<div class="table" width="100%">
<div class="tr"><div class="td left" width="33%"><%:Hostname%></div><div class="td left"><%=luci.sys.hostname() or "?"%></div></div>
<div class="tr"><div class="td left" width="33%"><%:Model%></div><div class="td left"><%=pcdata(boardinfo.model or "?")%></div></div>
<div class="tr"><div class="td left" width="33%"><%:Architecture%></div><div class="td left"><%=pcdata(boardinfo.system or "?")%></div></div>
<div class="tr"><div class="td left" width="33%"><%:Firmware Version%></div><div class="td left">
<%=pcdata(ver.distname)%> <%=pcdata(ver.distversion)%> /
<%=pcdata(ver.luciname)%> (<%=pcdata(ver.luciversion)%>)
</div></div>
<div class="tr"><div class="td left" width="33%"><%:Kernel Version%></div><div class="td left"><%=unameinfo.release or "?"%></div></div>
<div class="tr"><div class="td left" width="33%"><%:Local Time%></div><div class="td left" id="localtime">-</div></div>
<div class="tr"><div class="td left" width="33%"><%:Uptime%></div><div class="td left" id="uptime">-</div></div>
<div class="tr"><div class="td left" width="33%"><%:Load Average%></div><div class="td left" id="loadavg">-</div></div>
</div>
</div>
<div class="cbi-section">
<h3><%:Memory%></h3>
<div class="table" width="100%">
<div class="tr"><div class="td left" width="33%"><%:Total Available%></div><div class="td left"><div id="memtotal" class="cbi-progressbar" title="-"><div></div></div></div></div>
<div class="tr"><div class="td left" width="33%"><%:Free%></div><div class="td left"><div id="memfree" class="cbi-progressbar" title="-"><div></div></div></div></div>
<div class="tr"><div class="td left" width="33%"><%:Buffered%></div><div class="td left"><div id="membuff" class="cbi-progressbar" title="-"><div></div></div></div></div>
</div>
</div>
<% if swapinfo.total > 0 then %>
<div class="cbi-section">
<h3><%:Swap%></h3>
<div class="table" width="100%">
<div class="tr"><div class="td left" width="33%"><%:Total Available%></div><div class="td left"><div id="swaptotal" class="cbi-progressbar" title="-"><div></div></div></div></div>
<div class="tr"><div class="td left" width="33%"><%:Free%></div><div class="td left"><div id="swapfree" class="cbi-progressbar" title="-"><div></div></div></div></div>
</div>
</div>
<% end %>
<div class="cbi-section">
<h3><%:Network%></h3>
<div id="upstream_status_table" class="network-status-table">
<p><em><%:Collecting data...%></em></p>
</div>
<div class="table" width="100%">
<div class="tr"><div class="td left" width="33%"><%:Active Connections%></div><div class="td left"><div id="conns" class="cbi-progressbar" title="-"><div></div></div></div></div>
</div>
</div>
<%
if has_dhcp then
include("lease_status")
end
%>
<% if has_dsl then %>
<div class="cbi-section">
<h3><%:DSL%></h3>
<div id="dsl_status_table" class="network-status-table">
<p><em><%:Collecting data...%></em></p>
</div>
</div>
<% end %>
<% if has_wifi then %>
<div class="cbi-section">
<h3><%:Wireless%></h3>
<div id="wifi_status_table" class="network-status-table">
<p><em><%:Collecting data...%></em></p>
</div>
</div>
<div class="cbi-section">
<h3><%:Associated Stations%></h3>
<%+wifi_assoclist%>
</div>
<% end %>
<%-
local incdir = util.libpath() .. "/view/admin_status/index/"
if fs.access(incdir) then
local inc
for inc in fs.dir(incdir) do
if inc:match("%.htm$") then
include("admin_status/index/" .. inc:gsub("%.htm$", ""))
end
end
end
-%>
<script type="text/javascript" src="<%=resource%>/view/status/index.js"></script>
<%+footer%>
|