Merge branch 'Toastman-RT' into Toastman-RT-N
[tomato.git] / release / src / router / www / status-overview.asp
blob2836be9d8640dc27e22ab98c531cc698177a3288
1 <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0//EN'>
2 <!--
3 Tomato GUI
4 Copyright (C) 2006-2010 Jonathan Zarate
5 http://www.polarcloud.com/tomato/
7 Tomato VLAN GUI
8 Copyright (C) 2011 Augusto Bott
9 http://code.google.com/p/tomato-sdhc-vlan/
11 For use with Tomato Firmware only.
12 No part of this file may be used without permission.
13 -->
14 <html>
15 <head>
16 <meta http-equiv='content-type' content='text/html;charset=utf-8'>
17 <meta name='robots' content='noindex,nofollow'>
18 <title>[<% ident(); %>] Status: Overview</title>
19 <link rel='stylesheet' type='text/css' href='tomato.css'>
20 <% css(); %>
21 <script type='text/javascript' src='tomato.js'></script>
22 <script type='text/javascript' src='interfaces.js'></script>
24 <!-- / / / -->
26 <style type='text/css'>
27 .controls {
28 width: 90px;
29 margin-top: 5px;
30 margin-bottom: 10px;
32 </style>
34 <script type='text/javascript' src='debug.js'></script>
36 <script type='text/javascript'>
38 // <% nvstat(); %>
39 // <% etherstates(); %>
41 wmo = {'ap':'Access Point','sta':'Wireless Client','wet':'Wireless Ethernet Bridge','wds':'WDS'};
42 auth = {'disabled':'-','wep':'WEP','wpa_personal':'WPA Personal (PSK)','wpa_enterprise':'WPA Enterprise','wpa2_personal':'WPA2 Personal (PSK)','wpa2_enterprise':'WPA2 Enterprise','wpaX_personal':'WPA / WPA2 Personal','wpaX_enterprise':'WPA / WPA2 Enterprise','radius':'Radius'};
43 enc = {'tkip':'TKIP','aes':'AES','tkip+aes':'TKIP / AES'};
44 bgmo = {'disabled':'-','mixed':'Auto','b-only':'B Only','g-only':'G Only','bg-mixed':'B/G Mixed','lrs':'LRS','n-only':'N Only'};
46 lastjiffiestotal = 0;
47 lastjiffiesidle = 0;
48 lastjiffiesusage = 100;
49 </script>
51 <script type='text/javascript' src='wireless.jsx?_http_id=<% nv(http_id); %>'></script>
52 <script type='text/javascript' src='status-data.jsx?_http_id=<% nv(http_id); %>'></script>
54 <script type='text/javascript'>
55 show_dhcpc = ((nvram.wan_proto == 'dhcp') || (((nvram.wan_proto == 'l2tp') || (nvram.wan_proto == 'pptp')) && (nvram.pptp_dhcp == '1')));
56 show_codi = ((nvram.wan_proto == 'pppoe') || (nvram.wan_proto == 'l2tp') || (nvram.wan_proto == 'pptp') || (nvram.wan_proto == 'ppp3g'));
58 show_radio = [];
59 for (var uidx = 0; uidx < wl_ifaces.length; ++uidx) {
60 /* REMOVE-BEGIN
61 // show_radio.push((nvram['wl'+wl_unit(uidx)+'_radio'] == '1'));
62 REMOVE-END */
63 if (wl_sunit(uidx)<0)
64 show_radio.push((nvram['wl'+wl_fface(uidx)+'_radio'] == '1'));
67 nphy = features('11n');
69 function dhcpc(what)
71 form.submitHidden('dhcpc.cgi', { exec: what, _redirect: 'status-overview.asp' });
74 function serv(service, sleep)
76 form.submitHidden('service.cgi', { _service: service, _redirect: 'status-overview.asp', _sleep: sleep });
79 function wan_connect()
81 serv('wan-restart', 5);
84 function wan_disconnect()
86 serv('wan-stop', 2);
89 function wlenable(uidx, n)
91 form.submitHidden('wlradio.cgi', { enable: '' + n, _nextpage: 'status-overview.asp', _nextwait: n ? 6 : 3, _wl_unit: wl_unit(uidx) });
94 var ref = new TomatoRefresh('status-data.jsx', '', 0, 'status_overview_refresh');
96 ref.refresh = function(text)
98 stats = {};
99 try {
100 eval(text);
102 catch (ex) {
103 stats = {};
105 show();
109 function c(id, htm)
111 E(id).cells[1].innerHTML = htm;
114 function ethstates()
116 port = etherstates.port0;
117 if (port == "disable") { return 0; }
119 var state, state1, state2;
120 var code = '<div class="section-title">Ethernet Ports State</div>';
121 code += '<table class="fields"><tr><td class="title indent1"><center>WAN</center></td><td><center>LAN 1</center></td><td><center>LAN 2</center></td><td><center>LAN 3</center></td><td><center>LAN 4</center></td><tr>';
123 if (port == "DOWN") {
124 state2 = port.replace("DOWN","Unplugged");
125 } else if ((port == "1000FD") || (port == "1000HD")) {
126 state1 = port.replace("HD","M Half");
127 state2 = state1.replace("FD","M Full");
128 } else {
129 state1 = port.replace("HD","M Half");
130 state2 = state1.replace("FD","M Full");
132 code += '<td class="title indent1"><center>' + state2 + '</center></td>';
134 port = etherstates.port1;
135 if (port == "DOWN") {
136 state2 = port.replace("DOWN","Down");
137 } else if ((port == "1000FD") || (port == "1000HD")) {
138 state1 = port.replace("HD","M Half");
139 state2 = state1.replace("FD","M Full");
140 } else {
141 state1 = port.replace("HD","M Half");
142 state2 = state1.replace("FD","M Full");
144 code += '<td width="10%"><center>' + state2 + '</center></td>';
146 port = etherstates.port2;
147 if (port == "DOWN") {
148 state2 = port.replace("DOWN","Unplugged");
149 } else if ((port == "1000FD") || (port == "1000HD")) {
150 state1 = port.replace("HD","M Half");
151 state2 = state1.replace("FD","M Full");
152 } else {
153 state1 = port.replace("HD","M Half");
154 state2 = state1.replace("FD","M Full");
156 code += '<td width="10%"><center>' + state2 + '</center></td>';
158 port = etherstates.port3;
159 if (port == "DOWN") {
160 state2 = port.replace("DOWN","Unplugged");
161 } else if ((port == "1000FD") || (port == "1000HD")) {
162 state1 = port.replace("HD","M Half");
163 state2 = state1.replace("FD","M Full");
164 } else {
165 state1 = port.replace("HD","M Half");
166 state2 = state1.replace("FD","M Full");
168 code += '<td width="10%"><center>' + state2 + '</center></td>';
170 port = etherstates.port4;
171 if (port == "DOWN") {
172 state2 = port.replace("DOWN","Unplugged");
173 } else if ((port == "1000FD") || (port == "1000HD")) {
174 state1 = port.replace("HD","M Half");
175 state2 = state1.replace("FD","M Full");
176 } else {
177 state1 = port.replace("HD","M Half");
178 state2 = state1.replace("FD","M Full");
180 code += '<td width="10%"><center>' + state2 + '</center></td>';
182 code += '<td class="content"> </td></tr>';
183 E("ports").innerHTML = code;
186 function show()
188 c('cpu', stats.cpuload);
189 c('cpupercent', stats.cpupercent);
190 c('uptime', stats.uptime);
191 c('time', stats.time);
192 c('wanip', stats.wanip);
193 c('wanprebuf',stats.wanprebuf); //Victek
194 c('wannetmask', stats.wannetmask);
195 c('wangateway', stats.wangateway);
196 c('dns', stats.dns);
197 c('memory', stats.memory);
198 c('swap', stats.swap);
199 elem.display('swap', stats.swap != '');
201 /* IPV6-BEGIN */
202 c('ip6_wan', stats.ip6_wan);
203 elem.display('ip6_wan', stats.ip6_wan != '');
204 c('ip6_lan', stats.ip6_lan);
205 elem.display('ip6_lan', stats.ip6_lan != '');
206 c('ip6_lan_ll', stats.ip6_lan_ll);
207 elem.display('ip6_lan_ll', stats.ip6_lan_ll != '');
208 /* IPV6-END */
210 c('wanstatus', stats.wanstatus);
211 c('wanuptime', stats.wanuptime);
212 if (show_dhcpc) c('wanlease', stats.wanlease);
213 if (show_codi) {
214 E('b_connect').disabled = stats.wanup;
215 E('b_disconnect').disabled = !stats.wanup;
218 for (var uidx = 0; uidx < wl_ifaces.length; ++uidx) {
219 if (wl_sunit(uidx)<0) {
220 c('radio'+uidx, wlstats[uidx].radio ? 'Enabled' : '<b>Disabled</b>');
221 c('rate'+uidx, wlstats[uidx].rate);
222 if (show_radio[uidx]) {
223 E('b_wl'+uidx+'_enable').disabled = wlstats[uidx].radio;
224 E('b_wl'+uidx+'_disable').disabled = !wlstats[uidx].radio;
226 c('channel'+uidx, stats.channel[uidx]);
227 if (nphy) {
228 c('nbw'+uidx, wlstats[uidx].nbw);
230 c('interference'+uidx, stats.interference[uidx]);
231 elem.display('interference'+uidx, stats.interference[uidx] != '');
233 if (wlstats[uidx].client) {
234 c('rssi'+uidx, wlstats[uidx].rssi || '');
235 c('noise'+uidx, wlstats[uidx].noise || '');
236 c('qual'+uidx, stats.qual[uidx] || '');
239 c('ifstatus'+uidx, wlstats[uidx].ifstatus || '');
243 function earlyInit()
245 elem.display('b_dhcpc', show_dhcpc);
246 elem.display('b_connect', 'b_disconnect', show_codi);
247 if (nvram.wan_proto == 'disabled')
248 elem.display('wan-title', 'sesdiv_wan', 0);
249 for (var uidx = 0; uidx < wl_ifaces.length; ++uidx) {
250 if (wl_sunit(uidx)<0)
251 elem.display('b_wl'+wl_fface(uidx)+'_enable', 'b_wl'+wl_fface(uidx)+'_disable', show_radio[uidx]);
254 ethstates();
256 show();
259 function init() {
260 var c;
261 if (((c = cookie.get('status_overview_system_vis')) != null) && (c != '1')) toggleVisibility("system");
262 if (((c = cookie.get('status_overview_wan_vis')) != null) && (c != '1')) toggleVisibility("wan");
263 if (((c = cookie.get('status_overview_lan_vis')) != null) && (c != '1')) toggleVisibility("lan");
264 for (var uidx = 0; uidx < wl_ifaces.length; ++uidx) {
265 u = wl_fface(uidx);
266 if (((c = cookie.get('status_overview_wl_'+u+'_vis')) != null) && (c != '1')) toggleVisibility("wl_"+u);
268 ref.initPage(3000, 3);
271 function toggleVisibility(whichone) {
272 if (E('sesdiv_' + whichone).style.display == '') {
273 E('sesdiv_' + whichone).style.display = 'none';
274 E('sesdiv_' + whichone + '_showhide').innerHTML = '(Click here to show)';
275 cookie.set('status_overview_' + whichone + '_vis', 0);
276 } else {
277 E('sesdiv_' + whichone).style.display='';
278 E('sesdiv_' + whichone + '_showhide').innerHTML = '(Click here to hide)';
279 cookie.set('status_overview_' + whichone + '_vis', 1);
282 </script>
284 </head>
285 <body onload='init()'>
286 <form>
287 <table id='container' cellspacing=0>
288 <tr><td colspan=2 id='header'>
289 <div class='title'>Tomato</div>
290 <div class='version'>Version <% version(); %></div>
291 </td></tr>
292 <tr id='body'><td id='navi'><script type='text/javascript'>navi()</script></td>
293 <td id='content'>
294 <div id='ident'><% ident(); %></div>
296 <!-- / / / -->
298 <div class='section-title'>System <small><i><a href='javascript:toggleVisibility("system");'><span id='sesdiv_system_showhide'>(Click here to hide)</span></a></i></small></div>
299 <div class='section' id='sesdiv_system'>
300 <script type='text/javascript'>
301 var a = nvstat.free / nvstat.size * 100.0;
302 createFieldTable('', [
303 { title: 'Name', text: nvram.router_name },
304 { title: 'Model', text: nvram.t_model_name },
305 { title: 'Chipset', text: stats.systemtype },
306 { title: 'CPU Freq', text: stats.cpumhz },
307 { title: 'Flash Size', text: stats.flashsize },
308 null,
309 { title: 'Time', rid: 'time', text: stats.time },
310 { title: 'Uptime', rid: 'uptime', text: stats.uptime },
311 { title: 'CPU Load <small>(1 / 5 / 15 mins)</small>', rid: 'cpu', text: stats.cpuload },
312 { title: 'CPU Usage', rid: 'cpupercent', text: stats.cpupercent },
313 { title: 'Total / Free Memory', rid: 'memory', text: stats.memory },
314 { title: 'Total / Free Swap', rid: 'swap', text: stats.swap, hidden: (stats.swap == '') },
315 { title: 'Total / Free NVRAM', text: scaleSize(nvstat.size) + ' / ' + scaleSize(nvstat.free) + ' <small>(' + (a).toFixed(2) + '%)</small>' }
317 </script>
318 </div>
320 <div class='section' id='ports'>
321 </div>
323 <div class='section-title' id='wan-title'>WAN <small><i><a href='javascript:toggleVisibility("wan");'><span id='sesdiv_wan_showhide'>(hide)</span></a></i></small></div>
324 <div class='section' id='sesdiv_wan'>
325 <script type='text/javascript'>
326 createFieldTable('', [
327 { title: 'MAC Address', text: nvram.wan_hwaddr },
328 { title: 'Connection Type', text: { 'dhcp':'DHCP', 'static':'Static IP', 'pppoe':'PPPoE', 'pptp':'PPTP', 'l2tp':'L2TP', 'ppp3g':'3G Modem' }[nvram.wan_proto] || '-' },
329 { title: 'IP Address', rid: 'wanip', text: stats.wanip },
330 { title: 'Previous WAN IP', rid: 'wanprebuf', text: stats.wanprebuf, hidden: ((nvram.wan_proto != 'pppoe') && (nvram.wan_proto != 'pptp') && (nvram.wan_proto != 'l2tp') && (nvram.wan_proto != 'ppp3g')) }, //Victek
331 { title: 'Subnet Mask', rid: 'wannetmask', text: stats.wannetmask },
332 { title: 'Gateway', rid: 'wangateway', text: stats.wangateway },
333 /* IPV6-BEGIN */
334 { title: 'IPv6 Address', rid: 'ip6_wan', text: stats.ip6_wan, hidden: (stats.ip6_wan == '') },
335 /* IPV6-END */
336 { title: 'DNS', rid: 'dns', text: stats.dns },
337 { title: 'MTU', text: nvram.wan_run_mtu },
338 null,
339 { title: 'Status', rid: 'wanstatus', text: stats.wanstatus },
340 { title: 'Connection Uptime', rid: 'wanuptime', text: stats.wanuptime },
341 { title: 'Remaining Lease Time', rid: 'wanlease', text: stats.wanlease, ignore: !show_dhcpc }
343 </script>
344 <span id='b_dhcpc' style='display:none'>
345 <input type='button' class='controls' onclick='dhcpc("renew")' value='Renew'>
346 <input type='button' class='controls' onclick='dhcpc("release")' value='Release'> &nbsp;
347 </span>
348 <input type='button' class='controls' onclick='wan_connect()' value='Connect' id='b_connect' style='display:none'>
349 <input type='button' class='controls' onclick='wan_disconnect()' value='Disconnect' id='b_disconnect' style='display:none'>
350 </div>
353 <div class='section-title'>LAN <small><i><a href='javascript:toggleVisibility("lan");'><span id='sesdiv_lan_showhide'>(Click here to hide)</span></a></i></small></div>
354 <div class='section' id='sesdiv_lan'>
355 <script type='text/javascript'>
357 /* VLAN-BEGIN */
358 var s='';
359 var t='';
360 for (var i = 0 ; i <= MAX_BRIDGE_ID ; i++) {
361 var j = (i == 0) ? '' : i.toString();
362 if (nvram['lan' + j + '_ifname'].length > 0) {
363 if (nvram['lan' + j + '_proto'] == 'dhcp') {
364 if ((!fixIP(nvram.dhcpd_startip)) || (!fixIP(nvram.dhcpd_endip))) {
365 var x = nvram['lan' + j + '_ipaddr'].split('.').splice(0, 3).join('.') + '.';
366 nvram['dhcpd' + j + '_startip'] = x + nvram['dhcp' + j + '_start'];
367 nvram['dhcpd' + j + '_endip'] = x + ((nvram['dhcp' + j + '_start'] * 1) + (nvram['dhcp' + j + '_num'] * 1) - 1);
369 s += ((s.length>0)&&(s.charAt(s.length-1) != ' ')) ? '<br>' : '';
370 s += '<b>br' + i + '</b> (LAN' + j + ') - ' + nvram['dhcpd' + j + '_startip'] + ' - ' + nvram['dhcpd' + j + '_endip'];
371 } else {
372 s += ((s.length>0)&&(s.charAt(s.length-1) != ' ')) ? '<br>' : '';
373 s += '<b>br' + i + '</b> (LAN' + j + ') - Disabled';
375 t += ((t.length>0)&&(t.charAt(t.length-1) != ' ')) ? '<br>' : '';
376 t += '<b>br' + i + '</b> (LAN' + j + ') - ' + nvram['lan' + j + '_ipaddr'] + '/' + numberOfBitsOnNetMask(nvram['lan' + j + '_netmask']);
381 createFieldTable('', [
382 { title: 'Router MAC Address', text: nvram.et0macaddr },
383 { title: 'Router IP Addresses', text: t },
384 { title: 'Gateway', text: nvram.lan_gateway, ignore: nvram.wan_proto != 'disabled' },
385 /* IPV6-BEGIN */
386 { title: 'Router IPv6 Address', rid: 'ip6_lan', text: stats.ip6_lan, hidden: (stats.ip6_lan == '') },
387 { title: 'IPv6 Link-local Address', rid: 'ip6_lan_ll', text: stats.ip6_lan_ll, hidden: (stats.ip6_lan_ll == '') },
388 /* IPV6-END */
389 { title: 'DNS', rid: 'dns', text: stats.dns, ignore: nvram.wan_proto != 'disabled' },
390 { title: 'DHCP', text: s }
392 /* VLAN-END */
394 /* NOVLAN-BEGIN */
395 if (nvram.lan_proto == 'dhcp') {
396 if ((!fixIP(nvram.dhcpd_startip)) || (!fixIP(nvram.dhcpd_endip))) {
397 var x = nvram.lan_ipaddr.split('.').splice(0, 3).join('.') + '.';
398 nvram.dhcpd_startip = x + nvram.dhcp_start;
399 nvram.dhcpd_endip = x + ((nvram.dhcp_start * 1) + (nvram.dhcp_num * 1) - 1);
401 s = '<a href="status-devices.asp">' + nvram.dhcpd_startip + ' - ' + nvram.dhcpd_endip + '</a>';
403 else {
404 s = 'Disabled';
406 createFieldTable('', [
407 { title: 'Router MAC Address', text: nvram.et0macaddr },
408 { title: 'Router IP Address', text: nvram.lan_ipaddr },
409 { title: 'Subnet Mask', text: nvram.lan_netmask },
410 { title: 'Gateway', text: nvram.lan_gateway, ignore: nvram.wan_proto != 'disabled' },
411 /* IPV6-BEGIN */
412 { title: 'Router IPv6 Address', rid: 'ip6_lan', text: stats.ip6_lan, hidden: (stats.ip6_lan == '') },
413 { title: 'IPv6 Link-local Address', rid: 'ip6_lan_ll', text: stats.ip6_lan_ll, hidden: (stats.ip6_lan_ll == '') },
414 /* IPV6-END */
415 { title: 'DNS', rid: 'dns', text: stats.dns, ignore: nvram.wan_proto != 'disabled' },
416 { title: 'DHCP', text: s }
418 /* NOVLAN-END */
420 </script>
421 </div>
423 <script type='text/javascript'>
424 for (var uidx = 0; uidx < wl_ifaces.length; ++uidx) {
425 /* REMOVE-BEGIN
426 // u = wl_unit(uidx);
427 REMOVE-END */
428 u = wl_fface(uidx);
429 W('<div class=\'section-title\' id=\'wl'+u+'-title\'>Wireless');
430 if (wl_ifaces.length > 0)
431 W(' (' + wl_display_ifname(uidx) + ')');
432 W(' <small><i><a href=\'javascript:toggleVisibility("wl_' + u + '");\'><span id=\'sesdiv_wl_' +u + '_showhide\'>(Click here to hide)</span></a></i></small>');
433 W('</div>');
434 W('<div class=\'section\' id=\'sesdiv_wl_'+u+'\'>');
435 sec = auth[nvram['wl'+u+'_security_mode']] + '';
436 if (sec.indexOf('WPA') != -1) sec += ' + ' + enc[nvram['wl'+u+'_crypto']];
438 wmode = wmo[nvram['wl'+u+'_mode']] + '';
439 if ((nvram['wl'+u+'_mode'] == 'ap') && (nvram['wl'+u+'_wds_enable'] * 1)) wmode += ' + WDS';
441 createFieldTable('', [
442 { title: 'MAC Address', text: nvram['wl'+u+'_hwaddr'] },
443 { title: 'Wireless Mode', text: wmode },
444 { title: 'Wireless Network Mode', text: bgmo[nvram['wl'+u+'_net_mode']], ignore: (wl_sunit(uidx)>=0) },
445 { title: 'Interface Status', rid: 'ifstatus'+uidx, text: wlstats[uidx].ifstatus },
446 { title: 'Radio', rid: 'radio'+uidx, text: (wlstats[uidx].radio == 0) ? '<b>Disabled</b>' : 'Enabled', ignore: (wl_sunit(uidx)>=0) },
447 /* REMOVE-BEGIN */
448 // { title: 'SSID', text: (nvram['wl'+u+'_ssid'] + ' <small><i>' + ((nvram['wl'+u+'_mode'] != 'ap') ? '' : ((nvram['wl'+u+'_closed'] == 0) ? '(Broadcast Enabled)' : '(Broadcast Disabled)')) + '</i></small>') },
449 /* REMOVE-END */
450 { title: 'SSID', text: nvram['wl'+u+'_ssid'] },
451 { title: 'Broadcast', text: (nvram['wl'+u+'_closed'] == 0) ? 'Enabled' : '<b>Disabled</b>', ignore: (nvram['wl'+u+'_mode'] != 'ap') },
452 { title: 'Security', text: sec },
453 { title: 'Channel', rid: 'channel'+uidx, text: stats.channel[uidx], ignore: (wl_sunit(uidx)>=0) },
454 { title: 'Channel Width', rid: 'nbw'+uidx, text: wlstats[uidx].nbw, ignore: ((!nphy) || (wl_sunit(uidx)>=0)) },
455 { title: 'Interference Level', rid: 'interference'+uidx, text: stats.interference[uidx], hidden: ((stats.interference[uidx] == '') || (wl_sunit(uidx)>=0)) },
456 { title: 'Rate', rid: 'rate'+uidx, text: wlstats[uidx].rate, ignore: (wl_sunit(uidx)>=0) },
457 { title: 'RSSI', rid: 'rssi'+uidx, text: wlstats[uidx].rssi || '', ignore: ((!wlstats[uidx].client) || (wl_sunit(uidx)>=0)) },
458 { title: 'Noise', rid: 'noise'+uidx, text: wlstats[uidx].noise || '', ignore: ((!wlstats[uidx].client) || (wl_sunit(uidx)>=0)) },
459 { title: 'Signal Quality', rid: 'qual'+uidx, text: stats.qual[uidx] || '', ignore: ((!wlstats[uidx].client) || (wl_sunit(uidx)>=0)) }
462 W('<input type=\'button\' class=\'controls\' onclick=\'wlenable('+uidx+', 1)\' id=\'b_wl'+uidx+'_enable\' value=\'Enable\' style=\'display:none\'>');
463 W('<input type=\'button\' class=\'controls\' onclick=\'wlenable('+uidx+', 0)\' id=\'b_wl'+uidx+'_disable\' value=\'Disable\' style=\'display:none\'>');
464 W('</div>');
466 </script>
469 <!-- / / / -->
471 </td></tr>
472 <tr><td id='footer' colspan=2>
473 <script type='text/javascript'>genStdRefresh(1,0,'ref.toggle()');</script>
474 </td></tr>
475 </table>
476 </form>
477 <script type='text/javascript'>earlyInit()</script>
478 </body>
479 </html>