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