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