Merge pull request #1847 from dibdot/lxc_fix
[project/luci.git] / modules / luci-mod-admin-full / luasrc / view / admin_status / index.htm
1 <%#
2 Copyright 2008 Steven Barth <steven@midlink.org>
3 Copyright 2008-2011 Jo-Philipp Wich <jow@openwrt.org>
4 Licensed to the public under the Apache License 2.0.
5 -%>
6
7 <%
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"
13
14 local has_ipv6 = fs.access("/proc/net/ipv6_route")
15 local has_dhcp = fs.access("/etc/config/dhcp")
16 local has_wifi = ((fs.stat("/etc/config/wireless", "size") or 0) > 0)
17
18 local sysinfo = luci.util.ubus("system", "info") or { }
19 local boardinfo = luci.util.ubus("system", "board") or { }
20 local unameinfo = nixio.uname() or { }
21
22 local meminfo = sysinfo.memory or {
23 total = 0,
24 free = 0,
25 buffered = 0,
26 shared = 0
27 }
28
29 local swapinfo = sysinfo.swap or {
30 total = 0,
31 free = 0
32 }
33
34 local has_dsl = fs.access("/etc/init.d/dsl_control")
35
36 if luci.http.formvalue("status") == "1" then
37 local ntm = require "luci.model.network".init()
38 local wan = ntm:get_wannet()
39 local wan6 = ntm:get_wan6net()
40
41 local conn_count = tonumber(
42 fs.readfile("/proc/sys/net/netfilter/nf_conntrack_count") or "") or 0
43
44 local conn_max = tonumber(luci.sys.exec(
45 "sysctl -n -e net.nf_conntrack_max net.ipv4.netfilter.ip_conntrack_max"
46 ):match("%d+")) or 4096
47
48 local rv = {
49 uptime = sysinfo.uptime or 0,
50 localtime = os.date(),
51 loadavg = sysinfo.load or { 0, 0, 0 },
52 memory = meminfo,
53 swap = swapinfo,
54 connmax = conn_max,
55 conncount = conn_count,
56 leases = stat.dhcp_leases(),
57 leases6 = stat.dhcp6_leases(),
58 wifinets = stat.wifi_networks()
59 }
60
61 if wan then
62 local dev = wan:get_interface()
63 local link = dev and ipc.link(dev:name())
64 rv.wan = {
65 ipaddr = wan:ipaddr(),
66 gwaddr = wan:gwaddr(),
67 netmask = wan:netmask(),
68 dns = wan:dnsaddrs(),
69 expires = wan:expires(),
70 uptime = wan:uptime(),
71 proto = wan:proto(),
72 i18n = wan:get_i18n(),
73 ifname = wan:ifname(),
74 link = wan:adminlink(),
75 mac = dev and dev:mac(),
76 type = dev and dev:type(),
77 name = dev and dev:get_i18n(),
78 ether = link and link.type == 1
79 }
80 end
81
82 if wan6 then
83 local dev = wan6:get_interface()
84 local link = dev and ipc.link(dev:name())
85 rv.wan6 = {
86 ip6addr = wan6:ip6addr(),
87 gw6addr = wan6:gw6addr(),
88 dns = wan6:dns6addrs(),
89 ip6prefix = wan6:ip6prefix(),
90 uptime = wan6:uptime(),
91 proto = wan6:proto(),
92 i18n = wan6:get_i18n(),
93 ifname = wan6:ifname(),
94 link = wan6:adminlink(),
95 mac = dev and dev:mac(),
96 type = dev and dev:type(),
97 name = dev and dev:get_i18n(),
98 ether = link and link.type == 1
99 }
100 end
101
102 if has_dsl then
103 local dsl_stat = luci.sys.exec("/etc/init.d/dsl_control lucistat")
104 local dsl_func = loadstring(dsl_stat)
105 if dsl_func then
106 rv.dsl = dsl_func()
107 end
108 end
109
110 luci.http.prepare_content("application/json")
111 luci.http.write_json(rv)
112
113 return
114 elseif luci.http.formvalue("hosts") == "1" then
115 luci.http.prepare_content("application/json")
116 luci.http.write_json(luci.sys.net.host_hints())
117
118 return
119 end
120 -%>
121
122 <%+header%>
123
124 <script type="text/javascript" src="<%=resource%>/cbi.js"></script>
125 <script type="text/javascript">//<![CDATA[
126 function progressbar(v, m)
127 {
128 var vn = parseInt(v) || 0;
129 var mn = parseInt(m) || 100;
130 var pc = Math.floor((100 / mn) * vn);
131
132 return String.format(
133 '<div style="width:200px; position:relative; border:1px solid #999999">' +
134 '<div style="background-color:#CCCCCC; width:%d%%; height:15px">' +
135 '<div style="position:absolute; left:0; top:0; text-align:center; width:100%%; color:#000000">' +
136 '<small>%s / %s (%d%%)</small>' +
137 '</div>' +
138 '</div>' +
139 '</div>', pc, v, m, pc
140 );
141 }
142
143 function wifirate(bss, rx) {
144 var p = rx ? 'rx_' : 'tx_',
145 s = '%.1f <%:Mbit/s%>, %d<%:MHz%>'
146 .format(bss[p+'rate'] / 1000, bss[p+'mhz']),
147 ht = bss[p+'ht'], vht = bss[p+'vht'],
148 mhz = bss[p+'mhz'], nss = bss[p+'nss'],
149 mcs = bss[p+'mcs'], sgi = bss[p+'short_gi'];
150
151 if (ht || vht) {
152 if (vht) s += ', VHT-MCS %d'.format(mcs);
153 if (nss) s += ', VHT-NSS %d'.format(nss);
154 if (ht) s += ', MCS %s'.format(mcs);
155 if (sgi) s += ', <%:Short GI%>';
156 }
157
158 return s;
159 }
160
161 function duid2mac(duid) {
162 // DUID-LLT / Ethernet
163 if (duid.length === 28 && duid.substr(0, 8) === '00010001')
164 return duid.substr(16).replace(/(..)(?=..)/g, '$1:').toUpperCase();
165
166 // DUID-LL / Ethernet
167 if (duid.length === 20 && duid.substr(0, 8) === '00030001')
168 return duid.substr(8).replace(/(..)(?=..)/g, '$1:').toUpperCase();
169
170 return null;
171 }
172
173 var npoll = 1;
174 var hosts = <%=luci.http.write_json(luci.sys.net.host_hints())%>;
175
176 function updateHosts() {
177 XHR.get('<%=REQUEST_URI%>', { hosts: 1 }, function(x, data) {
178 hosts = data;
179 });
180 }
181
182 function labelList(items, offset) {
183 var rv = [ ];
184
185 for (var i = offset || 0; i < items.length; i += 2) {
186 var label = items[i],
187 value = items[i+1];
188
189 if (value === undefined || value === null)
190 continue;
191
192 if (label)
193 rv.push(E('strong', [label, ': ']));
194
195 rv.push(value, E('br'));
196 }
197
198 return rv;
199 }
200
201 function renderBox(title, active, childs) {
202 childs = childs || [];
203 childs.unshift(E('span', labelList(arguments, 3)));
204
205 return E('div', { class: 'ifacebox' }, [
206 E('div', { class: 'ifacebox-head center ' + (active ? 'active' : '') },
207 E('strong', title)),
208 E('div', { class: 'ifacebox-body' }, childs)
209 ]);
210 }
211
212 function renderBadge(icon, title) {
213 return E('span', { class: 'ifacebadge' }, [
214 E('img', { src: icon, title: title || '' }),
215 E('span', labelList(arguments, 2))
216 ]);
217 }
218
219 XHR.poll(5, '<%=REQUEST_URI%>', { status: 1 },
220 function(x, info)
221 {
222 if (!(npoll++ % 5))
223 updateHosts();
224
225 var us = document.getElementById('upstream_status_table');
226
227 while (us.lastElementChild)
228 us.removeChild(us.lastElementChild);
229
230 var ifc = info.wan || {};
231
232 us.appendChild(renderBox(
233 '<%:IPv4 Upstream%>',
234 (ifc.ifname && ifc.proto != 'none'),
235 [ E('div', {}, renderBadge(
236 '<%=resource%>/icons/%s.png'.format((ifc && ifc.type) ? ifc.type : 'ethernet_disabled'), null,
237 '<%:Device%>', ifc ? (ifc.name || ifc.ifname || '-') : '-',
238 '<%:MAC-Address%>', (ifc && ifc.ether) ? ifc.mac : null)) ],
239 '<%:Protocol%>', ifc.i18n || E('em', '<%:Not connected%>'),
240 '<%:Address%>', (ifc.ipaddr) ? ifc.ipaddr : '0.0.0.0',
241 '<%:Netmask%>', (ifc.netmask && ifc.netmask != ifc.ipaddr) ? ifc.netmask : '255.255.255.255',
242 '<%:Gateway%>', (ifc.gwaddr) ? ifc.gwaddr : '0.0.0.0',
243 '<%:DNS%> 1', (ifc.dns) ? ifc.dns[0] : null,
244 '<%:DNS%> 2', (ifc.dns) ? ifc.dns[1] : null,
245 '<%:DNS%> 3', (ifc.dns) ? ifc.dns[2] : null,
246 '<%:DNS%> 4', (ifc.dns) ? ifc.dns[3] : null,
247 '<%:DNS%> 5', (ifc.dns) ? ifc.dns[4] : null,
248 '<%:Expires%>', (ifc.expires > -1) ? '%t'.format(ifc.expires) : null,
249 '<%:Connected%>', (ifc.uptime > 0) ? '%t'.format(ifc.uptime) : null));
250
251 <% if has_ipv6 then %>
252 var ifc6 = info.wan6 || {};
253
254 us.appendChild(renderBox(
255 '<%:IPv6 Upstream%>',
256 (ifc6.ifname && ifc6.proto != 'none'),
257 [ E('div', {}, renderBadge(
258 '<%=resource%>/icons/%s.png'.format(ifc6.type || 'ethernet_disabled'), null,
259 '<%:Device%>', ifc6 ? (ifc6.name || ifc6.ifname || '-') : '-',
260 '<%:MAC-Address%>', (ifc6 && ifc6.ether) ? ifc6.mac : null)) ],
261 '<%:Protocol%>', ifc6.i18n ? (ifc6.i18n + (ifc6.proto === 'dhcp' && ifc6.ip6prefix ? '-PD' : '')) : E('em', '<%:Not connected%>'),
262 '<%:Prefix Delegated%>', ifc6.ip6prefix,
263 '<%:Address%>', (ifc6.ip6prefix) ? (ifc6.ip6addr || null) : (ifc6.ipaddr || '::'),
264 '<%:Gateway%>', (ifc6.gw6addr) ? ifc6.gw6addr : '::',
265 '<%:DNS%> 1', (ifc6.dns) ? ifc6.dns[0] : null,
266 '<%:DNS%> 2', (ifc6.dns) ? ifc6.dns[1] : null,
267 '<%:DNS%> 3', (ifc6.dns) ? ifc6.dns[2] : null,
268 '<%:DNS%> 4', (ifc6.dns) ? ifc6.dns[3] : null,
269 '<%:DNS%> 5', (ifc6.dns) ? ifc6.dns[4] : null,
270 '<%:Connected%>', (ifc6.uptime > 0) ? '%t'.format(ifc6.uptime) : null));
271 <% end %>
272
273 <% if has_dsl then %>
274 var dsl_i = document.getElementById('dsl_i');
275 var dsl_s = document.getElementById('dsl_s');
276
277 var s = String.format(
278 '<strong><%:Status%>: </strong>%s<br />' +
279 '<strong><%:Line State%>: </strong>%s [0x%x]<br />' +
280 '<strong><%:Line Mode%>: </strong>%s<br />' +
281 '<strong><%:Annex%>: </strong>%s<br />' +
282 '<strong><%:Profile%>: </strong>%s<br />' +
283 '<strong><%:Data Rate%>: </strong>%s/s / %s/s<br />' +
284 '<strong><%:Max. Attainable Data Rate (ATTNDR)%>: </strong>%s/s / %s/s<br />' +
285 '<strong><%:Latency%>: </strong>%s / %s<br />' +
286 '<strong><%:Line Attenuation (LATN)%>: </strong>%s dB / %s dB<br />' +
287 '<strong><%:Signal Attenuation (SATN)%>: </strong>%s dB / %s dB<br />' +
288 '<strong><%:Noise Margin (SNR)%>: </strong>%s dB / %s dB<br />' +
289 '<strong><%:Aggregate Transmit Power(ACTATP)%>: </strong>%s dB / %s dB<br />' +
290 '<strong><%:Forward Error Correction Seconds (FECS)%>: </strong>%s / %s<br />' +
291 '<strong><%:Errored seconds (ES)%>: </strong>%s / %s<br />' +
292 '<strong><%:Severely Errored Seconds (SES)%>: </strong>%s / %s<br />' +
293 '<strong><%:Loss of Signal Seconds (LOSS)%>: </strong>%s / %s<br />' +
294 '<strong><%:Unavailable Seconds (UAS)%>: </strong>%s / %s<br />' +
295 '<strong><%:Header Error Code Errors (HEC)%>: </strong>%s / %s<br />' +
296 '<strong><%:Non Pre-emtive CRC errors (CRC_P)%>: </strong>%s / %s<br />' +
297 '<strong><%:Pre-emtive CRC errors (CRCP_P)%>: </strong>%s / %s<br />' +
298 '<strong><%:Line Uptime%>: </strong>%s<br />' +
299 '<strong><%:ATU-C System Vendor ID%>: </strong>%s<br />' +
300 '<strong><%:Power Management Mode%>: </strong>%s<br />',
301 info.dsl.line_state, info.dsl.line_state_detail,
302 info.dsl.line_state_num,
303 info.dsl.line_mode_s,
304 info.dsl.annex_s,
305 info.dsl.profile_s,
306 info.dsl.data_rate_down_s, info.dsl.data_rate_up_s,
307 info.dsl.max_data_rate_down_s, info.dsl.max_data_rate_up_s,
308 info.dsl.latency_num_down, info.dsl.latency_num_up,
309 info.dsl.line_attenuation_down, info.dsl.line_attenuation_up,
310 info.dsl.signal_attenuation_down, info.dsl.signal_attenuation_up,
311 info.dsl.noise_margin_down, info.dsl.noise_margin_up,
312 info.dsl.actatp_down, info.dsl.actatp_up,
313 info.dsl.errors_fec_near, info.dsl.errors_fec_far,
314 info.dsl.errors_es_near, info.dsl.errors_es_far,
315 info.dsl.errors_ses_near, info.dsl.errors_ses_far,
316 info.dsl.errors_loss_near, info.dsl.errors_loss_far,
317 info.dsl.errors_uas_near, info.dsl.errors_uas_far,
318 info.dsl.errors_hec_near, info.dsl.errors_hec_far,
319 info.dsl.errors_crc_p_near, info.dsl.errors_crc_p_far,
320 info.dsl.errors_crcp_p_near, info.dsl.errors_crcp_p_far,
321 info.dsl.line_uptime_s,
322 info.dsl.atuc_vendor_id,
323 info.dsl.power_mode_s
324 );
325
326 dsl_s.innerHTML = String.format('<small>%s</small>', s);
327 dsl_i.innerHTML = String.format(
328 '<img src="<%=resource%>/icons/ethernet.png" />' +
329 '<br /><small>DSL</small>'
330 );
331 <% end %>
332
333 <% if has_dhcp then %>
334 var ls = document.getElementById('lease_status_table');
335 if (ls)
336 {
337 /* clear all rows */
338 while (ls.firstElementChild !== ls.lastElementChild)
339 ls.removeChild(ls.lastElementChild);
340
341 for (var i = 0; i < info.leases.length; i++)
342 {
343 var timestr;
344
345 if (info.leases[i].expires === false)
346 timestr = '<em><%:unlimited%></em>';
347 else if (info.leases[i].expires <= 0)
348 timestr = '<em><%:expired%></em>';
349 else
350 timestr = String.format('%t', info.leases[i].expires);
351
352 ls.appendChild(E('<div class="tr cbi-section-table-row cbi-rowstyle-%d">'.format((i % 2) + 1), [
353 E('<div class="td">', info.leases[i].hostname ? info.leases[i].hostname : '?'),
354 E('<div class="td">', info.leases[i].ipaddr),
355 E('<div class="td">', info.leases[i].macaddr),
356 E('<div class="td">', timestr)
357 ]));
358 }
359
360 if (ls.firstElementChild === ls.lastElementChild)
361 ls.appendChild(E('<div class="tr cbi-section-table-row"><div class="td"><em><br /><%:There are no active leases.%></em></div></div>'));
362 }
363
364 var ls6 = document.getElementById('lease6_status_table');
365 if (ls6 && info.leases6)
366 {
367 ls6.parentNode.style.display = 'block';
368
369 /* clear all rows */
370 while (ls6.firstElementChild !== ls6.lastElementChild)
371 ls6.removeChild(ls6.lastElementChild);
372
373 for (var i = 0; i < info.leases6.length; i++)
374 {
375 var timestr;
376
377 if (info.leases6[i].expires === false)
378 timestr = '<em><%:unlimited%></em>';
379 else if (info.leases6[i].expires <= 0)
380 timestr = '<em><%:expired%></em>';
381 else
382 timestr = String.format('%t', info.leases6[i].expires);
383
384 var host = hosts[duid2mac(info.leases6[i].duid)],
385 name = info.leases6[i].hostname,
386 hint = null;
387
388 if (!name) {
389 if (host)
390 hint = host.name || host.ipv4 || host.ipv6;
391 }
392 else {
393 if (host && host.name && info.leases6[i].hostname != host.name)
394 hint = host.name;
395 }
396
397 ls6.appendChild(E('<div class="tr cbi-section-table-row cbi-rowstyle-%d">'.format((i % 2) + 1), [
398 E('<div class="td nowrap">', hint ? '<div>%h (%h)</div>'.format(name || '?', hint) : (name || '?')),
399 E('<div class="td nowrap">', info.leases6[i].ip6addr),
400 E('<div class="td nowrap">', info.leases6[i].duid),
401 E('<div class="td nowrap">', timestr)
402 ]));
403 }
404
405 if (ls6.firstElementChild === ls6.lastElementChild)
406 ls6.appendChild(E('<div class="tr cbi-section-table-row"><div class="td"><em><br /><%:There are no active leases.%></em></div></div>'));
407 }
408 <% end %>
409
410 <% if has_wifi then %>
411 var assoclist = [ ];
412
413 var ws = document.getElementById('wifi_status_table');
414 if (ws)
415 {
416 while (ws.lastElementChild)
417 ws.removeChild(ws.lastElementChild);
418
419 for (var didx = 0; didx < info.wifinets.length; didx++)
420 {
421 var dev = info.wifinets[didx];
422 var net0 = (dev.networks && dev.networks[0]) ? dev.networks[0] : {};
423 var vifs = [];
424
425 for (var nidx = 0; nidx < dev.networks.length; nidx++)
426 {
427 var net = dev.networks[nidx];
428 var is_assoc = (net.bssid != '00:00:00:00:00:00' && net.channel && !net.disabled);
429 var num_assoc = 0;
430
431 for (var bssid in net.assoclist)
432 {
433 var bss = net.assoclist[bssid];
434
435 bss.bssid = bssid;
436 bss.link = net.link;
437 bss.name = net.name;
438 bss.ifname = net.ifname;
439 bss.radio = dev.name;
440
441 assoclist.push(bss);
442 num_assoc++;
443 }
444
445 var icon;
446 if (!is_assoc)
447 icon = "<%=resource%>/icons/signal-none.png";
448 else if (net.quality == 0)
449 icon = "<%=resource%>/icons/signal-0.png";
450 else if (net.quality < 25)
451 icon = "<%=resource%>/icons/signal-0-25.png";
452 else if (net.quality < 50)
453 icon = "<%=resource%>/icons/signal-25-50.png";
454 else if (net.quality < 75)
455 icon = "<%=resource%>/icons/signal-50-75.png";
456 else
457 icon = "<%=resource%>/icons/signal-75-100.png";
458
459 vifs.push(renderBadge(
460 icon,
461 '<%:Signal%>: %d dBm / <%:Quality%>: %d%%'.format(net.signal, net.quality),
462 '<%:SSID%>', E('a', { href: net.link }, [ net.ssid || '?' ]),
463 '<%:Mode%>', net.mode,
464 '<%:BSSID%>', is_assoc ? (net.bssid || '-') : null,
465 '<%:Encryption%>', is_assoc ? net.encryption : null,
466 '<%:Associations%>', is_assoc ? (num_assoc || '-') : null,
467 null, is_assoc ? null : E('em', '<%:Wireless is disabled or not associated%>')));
468 }
469
470 ws.appendChild(renderBox(
471 dev.device, dev.up || net0.up,
472 [ E('div', vifs) ],
473 '<%:Type%>', dev.name.replace(/^Generic | Wireless Controller .+$/g, ''),
474 '<%:Channel%>', net0.channel ? '%d (%.3f <%:GHz%>)'.format(net0.channel, net0.frequency) : '-',
475 '<%:Bitrate%>', net0.bitrate ? '%d <%:Mbit/s%>'.format(net0.bitrate) : '-'));
476 }
477
478 if (!ws.lastElementChild)
479 ws.appendChild(E('<em><%:No information available%></em>'));
480 }
481
482 var ac = document.getElementById('wifi_assoc_table');
483 if (ac)
484 {
485 /* clear all rows */
486 while (ac.firstElementChild !== ac.lastElementChild)
487 ac.removeChild(ac.lastElementChild);
488
489 assoclist.sort(function(a, b) {
490 return (a.name == b.name)
491 ? (a.bssid < b.bssid)
492 : (a.name > b.name )
493 ;
494 });
495
496 for (var i = 0; i < assoclist.length; i++)
497 {
498 var icon;
499 var q = (-1 * (assoclist[i].noise - assoclist[i].signal)) / 5;
500 if (q < 1)
501 icon = "<%=resource%>/icons/signal-0.png";
502 else if (q < 2)
503 icon = "<%=resource%>/icons/signal-0-25.png";
504 else if (q < 3)
505 icon = "<%=resource%>/icons/signal-25-50.png";
506 else if (q < 4)
507 icon = "<%=resource%>/icons/signal-50-75.png";
508 else
509 icon = "<%=resource%>/icons/signal-75-100.png";
510
511 var host = hosts[assoclist[i].bssid],
512 name = host ? (host.name || host.ipv4 || host.ipv6) : null,
513 hint = (host && host.name && (host.ipv4 || host.ipv6)) ? (host.ipv4 || host.ipv6) : null;
514
515 ac.appendChild(E('<div class="tr cbi-section-table-row cbi-rowstyle-%d">'.format(1 + (i % 2)), [
516 E('<div class="td"><span class="ifacebadge" title="%q"><img src="<%=resource%>/icons/wifi.png" /> %h</span></div>'
517 .format(assoclist[i].radio, assoclist[i].ifname)),
518 E('<div class="td"><a href="%s" style="white-space:nowrap">%h</a></div>'
519 .format(assoclist[i].link, assoclist[i].name)),
520 E('<div class="td">',
521 assoclist[i].bssid),
522 E('<div class="td nowrap">',
523 hint ? '<div>%h (%h)</div>'.format(name || '?', hint) : (name || '?')),
524 E('<div class="td"><span class="ifacebadge" title="<%:Signal%>: %d <%:dBm%> / <%:Noise%>: %d <%:dBm%> / <%:SNR%>: %d"><img src="%s" /> %d / %d <%:dBm%></span></div>'
525 .format(assoclist[i].signal, assoclist[i].noise, assoclist[i].signal - assoclist[i].noise, icon, assoclist[i].signal, assoclist[i].noise)),
526 E('<div class="td nowrap">', [
527 E('<span style="white-space:nowrap">', wifirate(assoclist[i], true)),
528 E('<br />'),
529 E('<span style="white-space:nowrap">', wifirate(assoclist[i], false))
530 ])
531 ]));
532 }
533
534 if (ac.firstElementChild === ac.lastElementChild)
535 ac.appendChild(E('<div class="tr cbi-section-table-row"><div class="td"><em><br /><%:No information available%></em></div></div>'));
536 }
537 <% end %>
538
539 var e;
540
541 if (e = document.getElementById('localtime'))
542 e.innerHTML = info.localtime;
543
544 if (e = document.getElementById('uptime'))
545 e.innerHTML = String.format('%t', info.uptime);
546
547 if (e = document.getElementById('loadavg'))
548 e.innerHTML = String.format(
549 '%.02f, %.02f, %.02f',
550 info.loadavg[0] / 65535.0,
551 info.loadavg[1] / 65535.0,
552 info.loadavg[2] / 65535.0
553 );
554
555 if (e = document.getElementById('memtotal'))
556 e.innerHTML = progressbar(
557 ((info.memory.free + info.memory.buffered) / 1024) + " <%:kB%>",
558 (info.memory.total / 1024) + " <%:kB%>"
559 );
560
561 if (e = document.getElementById('memfree'))
562 e.innerHTML = progressbar(
563 (info.memory.free / 1024) + " <%:kB%>",
564 (info.memory.total / 1024) + " <%:kB%>"
565 );
566
567 if (e = document.getElementById('membuff'))
568 e.innerHTML = progressbar(
569 (info.memory.buffered / 1024) + " <%:kB%>",
570 (info.memory.total / 1024) + " <%:kB%>"
571 );
572
573 if (e = document.getElementById('swaptotal'))
574 e.innerHTML = progressbar(
575 (info.swap.free / 1024) + " <%:kB%>",
576 (info.swap.total / 1024) + " <%:kB%>"
577 );
578
579 if (e = document.getElementById('swapfree'))
580 e.innerHTML = progressbar(
581 (info.swap.free / 1024) + " <%:kB%>",
582 (info.swap.total / 1024) + " <%:kB%>"
583 );
584
585 if (e = document.getElementById('conns'))
586 e.innerHTML = progressbar(info.conncount, info.connmax);
587
588 }
589 );
590 //]]></script>
591
592 <h2 name="content"><%:Status%></h2>
593
594 <fieldset class="cbi-section">
595 <legend><%:System%></legend>
596
597 <div class="table" width="100%">
598 <div class="tr"><div class="td left" width="33%"><%:Hostname%></div><div class="td left"><%=luci.sys.hostname() or "?"%></div></div>
599 <div class="tr"><div class="td left" width="33%"><%:Model%></div><div class="td left"><%=pcdata(boardinfo.model or "?")%></div></div>
600 <div class="tr"><div class="td left" width="33%"><%:Architecture%></div><div class="td left"><%=pcdata(boardinfo.system or "?")%></div></div>
601 <div class="tr"><div class="td left" width="33%"><%:Firmware Version%></div><div class="td left">
602 <%=pcdata(ver.distname)%> <%=pcdata(ver.distversion)%> /
603 <%=pcdata(ver.luciname)%> (<%=pcdata(ver.luciversion)%>)
604 </div></div>
605 <div class="tr"><div class="td left" width="33%"><%:Kernel Version%></div><div class="td left"><%=unameinfo.release or "?"%></div></div>
606 <div class="tr"><div class="td left" width="33%"><%:Local Time%></div><div class="td left" id="localtime">-</div></div>
607 <div class="tr"><div class="td left" width="33%"><%:Uptime%></div><div class="td left" id="uptime">-</div></div>
608 <div class="tr"><div class="td left" width="33%"><%:Load Average%></div><div class="td left" id="loadavg">-</div></div>
609 </div>
610 </fieldset>
611
612 <fieldset class="cbi-section">
613 <legend><%:Memory%></legend>
614
615 <div class="table" width="100%">
616 <div class="tr"><div class="td left" width="33%"><%:Total Available%></div><div class="td left" id="memtotal">-</div></div>
617 <div class="tr"><div class="td left" width="33%"><%:Free%></div><div class="td left" id="memfree">-</div></div>
618 <div class="tr"><div class="td left" width="33%"><%:Buffered%></div><div class="td left" id="membuff">-</div></div>
619 </div>
620 </fieldset>
621
622 <% if swapinfo.total > 0 then %>
623 <fieldset class="cbi-section">
624 <legend><%:Swap%></legend>
625
626 <div class="table" width="100%">
627 <div class="tr"><div class="td left" width="33%"><%:Total Available%></div><div class="td left" id="swaptotal">-</div></div>
628 <div class="tr"><div class="td left" width="33%"><%:Free%></div><div class="td left" id="swapfree">-</div></div>
629 </div>
630 </fieldset>
631 <% end %>
632
633 <fieldset class="cbi-section">
634 <legend><%:Network%></legend>
635
636 <div id="upstream_status_table" class="network-status-table">
637 <em><%:Collecting data...%></em>
638 </div>
639
640 <div class="table" width="100%">
641 <div class="tr"><div class="td left" width="33%"><%:Active Connections%></div><div class="td left" id="conns">-</div></div>
642 </div>
643 </fieldset>
644
645 <% if has_dhcp then %>
646 <fieldset class="cbi-section">
647 <legend><%:DHCP Leases%></legend>
648
649 <div class="table cbi-section-table" id="lease_status_table">
650 <div class="tr cbi-section-table-titles">
651 <div class="th"><%:Hostname%></div>
652 <div class="th"><%:IPv4-Address%></div>
653 <div class="th"><%:MAC-Address%></div>
654 <div class="th"><%:Leasetime remaining%></div>
655 </div>
656 <div class="tr cbi-section-table-row">
657 <div class="td" colspan="4"><em><br /><%:Collecting data...%></em></div>
658 </div>
659 </div>
660 </fieldset>
661
662 <fieldset class="cbi-section" style="display:none">
663 <legend><%:DHCPv6 Leases%></legend>
664
665 <div class="table cbi-section-table" id="lease6_status_table">
666 <div class="tr cbi-section-table-titles">
667 <div class="th"><%:Host%></div>
668 <div class="th"><%:IPv6-Address%></div>
669 <div class="th"><%:DUID%></div>
670 <div class="th"><%:Leasetime remaining%></div>
671 </div>
672 <div class="tr cbi-section-table-row">
673 <div class="td" colspan="4"><em><br /><%:Collecting data...%></em></div>
674 </div>
675 </div>
676 </fieldset>
677 <% end %>
678
679 <% if has_dsl then %>
680 <fieldset class="cbi-section">
681 <legend><%:DSL%></legend>
682 <div class="table" width="100%">
683 <div class="tr">
684 <div class="td left" width="33%" style="vertical-align:top"><%:DSL Status%></div>
685 <div class="td">
686 <div class="table">
687 <div class="tr">
688 <div class="td" id="dsl_i" style="width:16px; text-align:center; padding:3px"><img src="<%=resource%>/icons/ethernet_disabled.png" /><br /><small>?</small></div>
689 <div class="td left" id="dsl_s" style="vertical-align:middle; padding: 3px"><em><%:Collecting data...%></em></div>
690 </div>
691 </div>
692 </div>
693 </div>
694 </div>
695 </fieldset>
696 <% end %>
697
698 <% if has_wifi then %>
699 <fieldset class="cbi-section">
700 <legend><%:Wireless%></legend>
701
702 <div id="wifi_status_table" class="network-status-table">
703 <em><%:Collecting data...%></em>
704 </div>
705 </fieldset>
706
707 <fieldset class="cbi-section">
708 <legend><%:Associated Stations%></legend>
709
710 <div class="table cbi-section-table valign-middle" id="wifi_assoc_table">
711 <div class="tr cbi-section-table-titles">
712 <div class="th">&#160;</div>
713 <div class="th"><%:Network%></div>
714 <div class="th"><%:MAC-Address%></div>
715 <div class="th"><%:Host%></div>
716 <div class="th"><%:Signal%> / <%:Noise%></div>
717 <div class="th"><%:RX Rate%> / <%:TX Rate%></div>
718 </div>
719 <div class="tr cbi-section-table-row">
720 <div class="td" colspan="6"><em><br /><%:Collecting data...%></em></div>
721 </div>
722 </div>
723 </fieldset>
724 <% end %>
725
726 <%-
727 local incdir = util.libpath() .. "/view/admin_status/index/"
728 if fs.access(incdir) then
729 local inc
730 for inc in fs.dir(incdir) do
731 if inc:match("%.htm$") then
732 include("admin_status/index/" .. inc:gsub("%.htm$", ""))
733 end
734 end
735 end
736 -%>
737
738 <%+footer%>