luci-mod-admin-full: fix displaying of VHT rates (#533)
[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         var npoll = 1;
148         var hosts = <%=luci.http.write_json(luci.sys.net.host_hints())%>;
149
150         function updateHosts() {
151                 XHR.get('<%=REQUEST_URI%>', { hosts: 1 }, function(x, data) {
152                         hosts = data;
153                 });
154         }
155
156         XHR.poll(5, '<%=REQUEST_URI%>', { status: 1 },
157                 function(x, info)
158                 {
159                         if (!(npoll++ % 5))
160                                 updateHosts();
161
162                         var si = document.getElementById('wan4_i');
163                         var ss = document.getElementById('wan4_s');
164                         var ifc = info.wan;
165
166                         if (ifc && ifc.ifname && ifc.proto != 'none')
167                         {
168                                 var s = String.format(
169                                         '<strong><%:Type%>: </strong>%s<br />' +
170                                         '<strong><%:Address%>: </strong>%s<br />' +
171                                         '<strong><%:Netmask%>: </strong>%s<br />' +
172                                         '<strong><%:Gateway%>: </strong>%s<br />',
173                                                 ifc.proto,
174                                                 (ifc.ipaddr) ? ifc.ipaddr : '0.0.0.0',
175                                                 (ifc.netmask && ifc.netmask != ifc.ipaddr) ? ifc.netmask : '255.255.255.255',
176                                                 (ifc.gwaddr) ? ifc.gwaddr : '0.0.0.0'
177                                 );
178
179                                 for (var i = 0; i < ifc.dns.length; i++)
180                                 {
181                                         s += String.format(
182                                                 '<strong><%:DNS%> %d: </strong>%s<br />',
183                                                 i + 1, ifc.dns[i]
184                                         );
185                                 }
186
187                                 if (ifc.expires > -1)
188                                 {
189                                         s += String.format(
190                                                 '<strong><%:Expires%>: </strong>%t<br />',
191                                                 ifc.expires
192                                         );
193                                 }
194
195                                 if (ifc.uptime > 0)
196                                 {
197                                         s += String.format(
198                                                 '<strong><%:Connected%>: </strong>%t<br />',
199                                                 ifc.uptime
200                                         );
201                                 }
202
203                                 ss.innerHTML = String.format('<small>%s</small>', s);
204                                 si.innerHTML = String.format(
205                                         '<img src="<%=resource%>/icons/ethernet.png" />' +
206                                         '<br /><small><a href="%s">%s</a></small>',
207                                                 ifc.link, ifc.ifname
208                                 );
209                         }
210                         else
211                         {
212                                 si.innerHTML = '<img src="<%=resource%>/icons/ethernet_disabled.png" /><br /><small>?</small>';
213                                 ss.innerHTML = '<em><%:Not connected%></em>';
214                         }
215
216                         <% if has_ipv6 then %>
217                         var si6 = document.getElementById('wan6_i');
218                         var ss6 = document.getElementById('wan6_s');
219                         var ifc6 = info.wan6;
220
221                         if (ifc6 && ifc6.ifname && ifc6.proto != 'none')
222                         {
223                                 var s = String.format(
224                                         '<strong><%:Address%>: </strong>%s<br />' +
225                                         '<strong><%:Gateway%>: </strong>%s<br />',
226                                                 (ifc6.ip6addr) ? ifc6.ip6addr : '::',
227                                                 (ifc6.gw6addr) ? ifc6.gw6addr : '::'
228                                 );
229
230                                 for (var i = 0; i < ifc6.dns.length; i++)
231                                 {
232                                         s += String.format(
233                                                 '<strong><%:DNS%> %d: </strong>%s<br />',
234                                                 i + 1, ifc6.dns[i]
235                                         );
236                                 }
237
238                                 if (ifc6.uptime > 0)
239                                 {
240                                         s += String.format(
241                                                 '<strong><%:Connected%>: </strong>%t<br />',
242                                                 ifc6.uptime
243                                         );
244                                 }
245
246                                 ss6.innerHTML = String.format('<small>%s</small>', s);
247                                 si6.innerHTML = String.format(
248                                         '<img src="<%=resource%>/icons/ethernet.png" />' +
249                                         '<br /><small><a href="%s">%s</a></small>',
250                                                 ifc6.link, ifc6.ifname
251                                 );
252                         }
253                         else
254                         {
255                                 si6.innerHTML = '<img src="<%=resource%>/icons/ethernet_disabled.png" /><br /><small>?</small>';
256                                 ss6.innerHTML = '<em><%:Not connected%></em>';
257                         }
258                         <% end %>
259
260                         <% if has_dsl then %>
261                                 var dsl_i = document.getElementById('dsl_i');
262                                 var dsl_s = document.getElementById('dsl_s');
263
264                                 var s = String.format(
265                                         '<strong><%:Status%>: </strong>%s<br />' +
266                                         '<strong><%:Line State%>: </strong>%s [0x%x]<br />' +
267                                         '<strong><%:Line Speed%>: </strong>%s/s / %s/s<br />' +
268                                         '<strong><%:Line Attenuation%>: </strong>%s dB / %s dB<br />' +
269                                         '<strong><%:Noise Margin%>: </strong>%s dB / %s dB<br />',
270                                                 info.dsl.line_state, info.dsl.line_state_detail,
271                                                 info.dsl.line_state_num,
272                                                 info.dsl.data_rate_down_s, info.dsl.data_rate_up_s,
273                                                 info.dsl.line_attenuation_down, info.dsl.line_attenuation_up,
274                                                 info.dsl.noise_margin_down, info.dsl.noise_margin_up
275                                 );
276
277                                 dsl_s.innerHTML = String.format('<small>%s</small>', s);
278                                 dsl_i.innerHTML = String.format(
279                                         '<img src="<%=resource%>/icons/ethernet.png" />' +
280                                         '<br /><small>ADSL</small>'
281                                 );
282                         <% end %>
283
284                         <% if has_dhcp then %>
285                         var ls = document.getElementById('lease_status_table');
286                         if (ls)
287                         {
288                                 /* clear all rows */
289                                 while( ls.rows.length > 1 )
290                                         ls.rows[0].parentNode.deleteRow(1);
291
292                                 for( var i = 0; i < info.leases.length; i++ )
293                                 {
294                                         var timestr;
295
296                                         if (info.leases[i].expires <= 0)
297                                                 timestr = '<em><%:expired%></em>';
298                                         else
299                                                 timestr = String.format('%t', info.leases[i].expires);
300
301                                         var tr = ls.rows[0].parentNode.insertRow(-1);
302                                                 tr.className = 'cbi-section-table-row cbi-rowstyle-' + ((i % 2) + 1);
303
304                                         tr.insertCell(-1).innerHTML = info.leases[i].hostname ? info.leases[i].hostname : '?';
305                                         tr.insertCell(-1).innerHTML = info.leases[i].ipaddr;
306                                         tr.insertCell(-1).innerHTML = info.leases[i].macaddr;
307                                         tr.insertCell(-1).innerHTML = timestr;
308                                 }
309
310                                 if( ls.rows.length == 1 )
311                                 {
312                                         var tr = ls.rows[0].parentNode.insertRow(-1);
313                                                 tr.className = 'cbi-section-table-row';
314
315                                         var td = tr.insertCell(-1);
316                                                 td.colSpan = 4;
317                                                 td.innerHTML = '<em><br /><%:There are no active leases.%></em>';
318                                 }
319                         }
320
321                         var ls6 = document.getElementById('lease6_status_table');
322                         if (ls6 && info.leases6)
323                         {
324                                 ls6.parentNode.style.display = 'block';
325
326                                 /* clear all rows */
327                                 while( ls6.rows.length > 1 )
328                                         ls6.rows[0].parentNode.deleteRow(1);
329
330                                 for( var i = 0; i < info.leases6.length; i++ )
331                                 {
332                                         var timestr;
333
334                                         if (info.leases6[i].expires <= 0)
335                                                 timestr = '<em><%:expired%></em>';
336                                         else
337                                                 timestr = String.format('%t', info.leases6[i].expires);
338
339                                         var tr = ls6.rows[0].parentNode.insertRow(-1);
340                                                 tr.className = 'cbi-section-table-row cbi-rowstyle-' + ((i % 2) + 1);
341
342                                         tr.insertCell(-1).innerHTML = info.leases6[i].hostname ? info.leases6[i].hostname : '?';
343                                         tr.insertCell(-1).innerHTML = info.leases6[i].ip6addr;
344                                         tr.insertCell(-1).innerHTML = info.leases6[i].duid;
345                                         tr.insertCell(-1).innerHTML = timestr;
346                                 }
347
348                                 if( ls6.rows.length == 1 )
349                                 {
350                                         var tr = ls6.rows[0].parentNode.insertRow(-1);
351                                                 tr.className = 'cbi-section-table-row';
352
353                                         var td = tr.insertCell(-1);
354                                                 td.colSpan = 4;
355                                                 td.innerHTML = '<em><br /><%:There are no active leases.%></em>';
356                                 }
357                         }
358                         <% end %>
359
360                         <% if has_wifi then %>
361                         var assoclist = [ ];
362
363                         var ws = document.getElementById('wifi_status_table');
364                         if (ws)
365                         {
366                                 var wsbody = ws.rows[0].parentNode;
367                                 while (ws.rows.length > 0)
368                                         wsbody.deleteRow(0);
369
370                                 for (var didx = 0; didx < info.wifinets.length; didx++)
371                                 {
372                                         var dev = info.wifinets[didx];
373
374                                         var tr = wsbody.insertRow(-1);
375                                         var td;
376
377                                         td = tr.insertCell(-1);
378                                         td.width     = "33%";
379                                         td.innerHTML = dev.name;
380                                         td.style.verticalAlign = "top";
381
382                                         td = tr.insertCell(-1);
383
384                                         var s = '';
385
386                                         for (var nidx = 0; nidx < dev.networks.length; nidx++)
387                                         {
388                                                 var net = dev.networks[nidx];
389                                                 var is_assoc = (net.bssid != '00:00:00:00:00:00' && net.channel && !net.disabled);
390
391                                                 var icon;
392                                                 if (!is_assoc)
393                                                         icon = "<%=resource%>/icons/signal-none.png";
394                                                 else if (net.quality == 0)
395                                                         icon = "<%=resource%>/icons/signal-0.png";
396                                                 else if (net.quality < 25)
397                                                         icon = "<%=resource%>/icons/signal-0-25.png";
398                                                 else if (net.quality < 50)
399                                                         icon = "<%=resource%>/icons/signal-25-50.png";
400                                                 else if (net.quality < 75)
401                                                         icon = "<%=resource%>/icons/signal-50-75.png";
402                                                 else
403                                                         icon = "<%=resource%>/icons/signal-75-100.png";
404
405                                                 s += String.format(
406                                                         '<table><tr><td style="text-align:center; width:32px; padding:3px">' +
407                                                                 '<img src="%s" title="<%:Signal%>: %d dBm / <%:Noise%>: %d dBm" />' +
408                                                                 '<br /><small>%d%%</small>' +
409                                                         '</td><td style="text-align:left; padding:3px"><small>' +
410                                                                 '<strong><%:SSID%>:</strong> <a href="%s">%h</a><br />' +
411                                                                 '<strong><%:Mode%>:</strong> %s<br />' +
412                                                                 '<strong><%:Channel%>:</strong> %d (%.3f <%:GHz%>)<br />' +
413                                                                 '<strong><%:Bitrate%>:</strong> %s <%:Mbit/s%><br />',
414                                                                 icon, net.signal, net.noise,
415                                                                 net.quality,
416                                                                 net.link, net.ssid,
417                                                                 net.mode,
418                                                                 net.channel, net.frequency,
419                                                                 net.bitrate || '?'
420                                                 );
421
422                                                 if (is_assoc)
423                                                 {
424                                                         s += String.format(
425                                                                 '<strong><%:BSSID%>:</strong> %s<br />' +
426                                                                 '<strong><%:Encryption%>:</strong> %s',
427                                                                         net.bssid,
428                                                                         net.encryption
429                                                         );
430                                                 }
431                                                 else
432                                                 {
433                                                         s += '<em><%:Wireless is disabled or not associated%></em>';
434                                                 }
435
436                                                 s += '</small></td></tr></table>';
437
438                                                 for (var bssid in net.assoclist)
439                                                 {
440                                                         var bss = net.assoclist[bssid];
441
442                                                         bss.bssid  = bssid;
443                                                         bss.link   = net.link;
444                                                         bss.name   = net.name;
445                                                         bss.ifname = net.ifname;
446                                                         bss.radio  = dev.name;
447
448                                                         assoclist.push(bss);
449                                                 }
450                                         }
451
452                                         if (!s)
453                                                 s = '<em><%:No information available%></em>';
454
455                                         td.innerHTML = s;
456                                 }
457                         }
458
459                         var ac = document.getElementById('wifi_assoc_table');
460                         if (ac)
461                         {
462                                 /* clear all rows */
463                                 while( ac.rows.length > 1 )
464                                         ac.rows[0].parentNode.deleteRow(1);
465
466                                 assoclist.sort(function(a, b) {
467                                         return (a.name == b.name)
468                                                 ? (a.bssid < b.bssid)
469                                                 : (a.name  > b.name )
470                                         ;
471                                 });
472
473                                 for( var i = 0; i < assoclist.length; i++ )
474                                 {
475                                         var tr = ac.rows[0].parentNode.insertRow(-1);
476                                                 tr.className = 'cbi-section-table-row cbi-rowstyle-' + (1 + (i % 2));
477
478                                         var icon;
479                                         var q = (-1 * (assoclist[i].noise - assoclist[i].signal)) / 5;
480                                         if (q < 1)
481                                                 icon = "<%=resource%>/icons/signal-0.png";
482                                         else if (q < 2)
483                                                 icon = "<%=resource%>/icons/signal-0-25.png";
484                                         else if (q < 3)
485                                                 icon = "<%=resource%>/icons/signal-25-50.png";
486                                         else if (q < 4)
487                                                 icon = "<%=resource%>/icons/signal-50-75.png";
488                                         else
489                                                 icon = "<%=resource%>/icons/signal-75-100.png";
490
491                                         tr.insertCell(-1).innerHTML = String.format(
492                                                 '<span class="ifacebadge" title="%q"><img src="<%=resource%>/icons/wifi.png" /> %h</span>',
493                                                 assoclist[i].radio, assoclist[i].ifname
494                                         );
495
496                                         tr.insertCell(-1).innerHTML = String.format(
497                                                 '<a href="%s">%s</a>',
498                                                         assoclist[i].link,
499                                                         '%h'.format(assoclist[i].name).nobr()
500                                         );
501
502                                         tr.insertCell(-1).innerHTML = assoclist[i].bssid;
503
504                                         var host = hosts[assoclist[i].bssid];
505                                         if (host)
506                                                 tr.insertCell(-1).innerHTML = String.format(
507                                                         '<div style="max-width:200px;overflow:hidden;text-overflow:ellipsis">%s</div>',
508                                                         ((host.name && (host.ipv4 || host.ipv6))
509                                                                 ? '%h (%s)'.format(host.name, host.ipv4 || host.ipv6)
510                                                                 : '%h'.format(host.name || host.ipv4 || host.ipv6)).nobr()
511                                                 );
512                                         else
513                                                 tr.insertCell(-1).innerHTML = '?';
514
515                                         tr.insertCell(-1).innerHTML = String.format(
516                                                 '<span class="ifacebadge" title="<%:Signal%>: %d <%:dBm%> / <%:Noise%>: %d <%:dBm%> / <%:SNR%>: %d"><img src="%s" /> %d / %d <%:dBm%></span>',
517                                                 assoclist[i].signal, assoclist[i].noise, assoclist[i].signal - assoclist[i].noise,
518                                                 icon,
519                                                 assoclist[i].signal, assoclist[i].noise
520                                         );
521
522                                         tr.insertCell(-1).innerHTML = wifirate(assoclist[i], true).nobr() + '<br />' + wifirate(assoclist[i], false).nobr();
523                                 }
524
525                                 if (ac.rows.length == 1)
526                                 {
527                                         var tr = ac.rows[0].parentNode.insertRow(-1);
528                                                 tr.className = 'cbi-section-table-row';
529
530                                         var td = tr.insertCell(-1);
531                                                 td.colSpan = 7;
532                                                 td.innerHTML = '<br /><em><%:No information available%></em>';
533                                 }
534                         }
535                         <% end %>
536
537                         var e;
538
539                         if (e = document.getElementById('localtime'))
540                                 e.innerHTML = info.localtime;
541
542                         if (e = document.getElementById('uptime'))
543                                 e.innerHTML = String.format('%t', info.uptime);
544
545                         if (e = document.getElementById('loadavg'))
546                                 e.innerHTML = String.format(
547                                         '%.02f, %.02f, %.02f',
548                                         info.loadavg[0] / 65535.0,
549                                         info.loadavg[1] / 65535.0,
550                                         info.loadavg[2] / 65535.0
551                                 );
552
553                         if (e = document.getElementById('memtotal'))
554                                 e.innerHTML = progressbar(
555                                         ((info.memory.free + info.memory.buffered) / 1024) + " <%:kB%>",
556                                         (info.memory.total / 1024) + " <%:kB%>"
557                                 );
558
559                         if (e = document.getElementById('memfree'))
560                                 e.innerHTML = progressbar(
561                                         (info.memory.free / 1024) + " <%:kB%>",
562                                         (info.memory.total / 1024) + " <%:kB%>"
563                                 );
564
565                         if (e = document.getElementById('membuff'))
566                                 e.innerHTML = progressbar(
567                                         (info.memory.buffered / 1024) + " <%:kB%>",
568                                         (info.memory.total / 1024) + " <%:kB%>"
569                                 );
570
571                         if (e = document.getElementById('swaptotal'))
572                                 e.innerHTML = progressbar(
573                                         (info.swap.free / 1024) + " <%:kB%>",
574                                         (info.swap.total / 1024) + " <%:kB%>"
575                                 );
576
577                         if (e = document.getElementById('swapfree'))
578                                 e.innerHTML = progressbar(
579                                         (info.swap.free / 1024) + " <%:kB%>",
580                                         (info.swap.total / 1024) + " <%:kB%>"
581                                 );
582
583                         if (e = document.getElementById('conns'))
584                                 e.innerHTML = progressbar(info.conncount, info.connmax);
585
586                 }
587         );
588 //]]></script>
589
590 <h2 name="content"><%:Status%></h2>
591
592 <fieldset class="cbi-section">
593         <legend><%:System%></legend>
594
595         <table width="100%" cellspacing="10">
596                 <tr><td width="33%"><%:Hostname%></td><td><%=luci.sys.hostname() or "?"%></td></tr>
597                 <tr><td width="33%"><%:Model%></td><td><%=pcdata(boardinfo.model or boardinfo.system or "?")%></td></tr>
598                 <tr><td width="33%"><%:Firmware Version%></td><td>
599                         <%=pcdata(ver.distname)%> <%=pcdata(ver.distversion)%> /
600                         <%=pcdata(ver.luciname)%> (<%=pcdata(ver.luciversion)%>)
601                 </td></tr>
602                 <tr><td width="33%"><%:Kernel Version%></td><td><%=unameinfo.release or "?"%></td></tr>
603                 <tr><td width="33%"><%:Local Time%></td><td id="localtime">-</td></tr>
604                 <tr><td width="33%"><%:Uptime%></td><td id="uptime">-</td></tr>
605                 <tr><td width="33%"><%:Load Average%></td><td id="loadavg">-</td></tr>
606         </table>
607 </fieldset>
608
609 <fieldset class="cbi-section">
610         <legend><%:Memory%></legend>
611
612         <table width="100%" cellspacing="10">
613                 <tr><td width="33%"><%:Total Available%></td><td id="memtotal">-</td></tr>
614                 <tr><td width="33%"><%:Free%></td><td id="memfree">-</td></tr>
615                 <tr><td width="33%"><%:Buffered%></td><td id="membuff">-</td></tr>
616         </table>
617 </fieldset>
618
619 <% if swapinfo.total > 0 then %>
620 <fieldset class="cbi-section">
621         <legend><%:Swap%></legend>
622
623         <table width="100%" cellspacing="10">
624                 <tr><td width="33%"><%:Total Available%></td><td id="swaptotal">-</td></tr>
625                 <tr><td width="33%"><%:Free%></td><td id="swapfree">-</td></tr>
626         </table>
627 </fieldset>
628 <% end %>
629
630 <fieldset class="cbi-section">
631         <legend><%:Network%></legend>
632
633         <table width="100%" cellspacing="10">
634                 <tr><td width="33%" style="vertical-align:top"><%:IPv4 WAN Status%></td><td>
635                         <table><tr>
636                                 <td id="wan4_i" style="width:16px; text-align:center; padding:3px"><img src="<%=resource%>/icons/ethernet_disabled.png" /><br /><small>?</small></td>
637                                 <td id="wan4_s" style="vertical-align:middle; padding: 3px"><em><%:Collecting data...%></em></td>
638                         </tr></table>
639                 </td></tr>
640                 <% if has_ipv6 then %>
641                 <tr><td width="33%" style="vertical-align:top"><%:IPv6 WAN Status%></td><td>
642                         <table><tr>
643                                 <td id="wan6_i" style="width:16px; text-align:center; padding:3px"><img src="<%=resource%>/icons/ethernet_disabled.png" /><br /><small>?</small></td>
644                                 <td id="wan6_s" style="vertical-align:middle; padding: 3px"><em><%:Collecting data...%></em></td>
645                         </tr></table>
646                 </td></tr>
647                 <% end %>
648                 <tr><td width="33%"><%:Active Connections%></td><td id="conns">-</td></tr>
649         </table>
650 </fieldset>
651
652 <% if has_dhcp then %>
653 <fieldset class="cbi-section">
654         <legend><%:DHCP Leases%></legend>
655
656         <table class="cbi-section-table" id="lease_status_table">
657                 <tr class="cbi-section-table-titles">
658                         <th class="cbi-section-table-cell"><%:Hostname%></th>
659                         <th class="cbi-section-table-cell"><%:IPv4-Address%></th>
660                         <th class="cbi-section-table-cell"><%:MAC-Address%></th>
661                         <th class="cbi-section-table-cell"><%:Leasetime remaining%></th>
662                 </tr>
663                 <tr class="cbi-section-table-row">
664                         <td colspan="4"><em><br /><%:Collecting data...%></em></td>
665                 </tr>
666         </table>
667 </fieldset>
668
669 <fieldset class="cbi-section" style="display:none">
670         <legend><%:DHCPv6 Leases%></legend>
671
672         <table class="cbi-section-table" id="lease6_status_table">
673                 <tr class="cbi-section-table-titles">
674                         <th class="cbi-section-table-cell"><%:Hostname%></th>
675                         <th class="cbi-section-table-cell"><%:IPv6-Address%></th>
676                         <th class="cbi-section-table-cell"><%:DUID%></th>
677                         <th class="cbi-section-table-cell"><%:Leasetime remaining%></th>
678                 </tr>
679                 <tr class="cbi-section-table-row">
680                         <td colspan="4"><em><br /><%:Collecting data...%></em></td>
681                 </tr>
682         </table>
683 </fieldset>
684 <% end %>
685
686 <% if has_dsl then %>
687 <fieldset class="cbi-section">
688        <legend><%:ADSL%></legend>
689        <table width="100%" cellspacing="10">
690                <tr><td width="33%" style="vertical-align:top"><%:ADSL Status%></td><td>
691                        <table><tr>
692                                <td id="dsl_i" style="width:16px; text-align:center; padding:3px"><img src="<%=resource%>/icons/ethernet_disabled.png" /><br /><small>?</small></td>
693                                <td id="dsl_s" style="vertical-align:middle; padding: 3px"><em><%:Collecting data...%></em></td>
694                        </tr></table>
695                </td></tr>
696        </table>
697 </fieldset>
698 <% end %>
699
700 <% if has_wifi then %>
701 <fieldset class="cbi-section">
702         <legend><%:Wireless%></legend>
703
704         <table id="wifi_status_table" width="100%" cellspacing="10">
705                 <tr><td><em><%:Collecting data...%></em></td></tr>
706         </table>
707 </fieldset>
708
709 <fieldset class="cbi-section">
710         <legend><%:Associated Stations%></legend>
711
712         <table class="cbi-section-table valign-middle" id="wifi_assoc_table">
713                 <tr class="cbi-section-table-titles">
714                         <th class="cbi-section-table-cell">&#160;</th>
715                         <th class="cbi-section-table-cell"><%:Network%></th>
716                         <th class="cbi-section-table-cell"><%:MAC-Address%></th>
717                         <th class="cbi-section-table-cell"><%:Host%></th>
718                         <th class="cbi-section-table-cell"><%:Signal%> / <%:Noise%></th>
719                         <th class="cbi-section-table-cell"><%:RX Rate%> / <%:TX Rate%></th>
720                 </tr>
721                 <tr class="cbi-section-table-row">
722                         <td colspan="6"><em><br /><%:Collecting data...%></em></td>
723                 </tr>
724         </table>
725 </fieldset>
726 <% end %>
727
728 <%-
729         local incdir = util.libpath() .. "/view/admin_status/index/"
730         if fs.access(incdir) then
731                 local inc
732                 for inc in fs.dir(incdir) do
733                         if inc:match("%.htm$") then
734                                 include("admin_status/index/" .. inc:gsub("%.htm$", ""))
735                         end
736                 end
737         end
738 -%>
739
740 <%+footer%>