3 Copyright (C) 2006-2010 Jonathan Zarate
4 http://www.polarcloud.com/tomato/
6 For use with Tomato Firmware only.
7 No part of this file may be used without permission.
11 //<% nvram("ppp_get_ip,pptp_server_ip,router_name,clkfreq,wan_ipaddr_buf,wan_domain,wan_gateway,wan_gateway_get,wan_get_domain,wan_hostname,wan_hwaddr,wan_ipaddr,wan_netmask,wan_proto,wan_run_mtu,et0macaddr,lan_proto,lan_ipaddr,dhcp_start,dhcp_num,dhcpd_startip,dhcpd_endip,lan_netmask,wl_security_mode,wl_crypto,wl_mode,wl_wds_enable,wl_hwaddr,wl_net_mode,wl_radio,wl_channel,lan_gateway,wl_ssid,t_model_name,t_features,pptp_dhcp"); %>
23 if (typeof(last_wan_proto) == 'undefined') {
24 last_wan_proto = nvram.wan_proto;
26 else if (last_wan_proto != nvram.wan_proto) {
29 stats.cpumhz = sysinfo.cpuclk+'MHz';
30 stats.systemtype = sysinfo.systemtype;
31 stats.cpuload = ((sysinfo.loads[0] / 65536.0).toFixed(2) + '<small> / </small> ' +
32 (sysinfo.loads[1] / 65536.0).toFixed(2) + '<small> / </small>' +
33 (sysinfo.loads[2] / 65536.0).toFixed(2));
34 stats.uptime = sysinfo.uptime_s;
37 b = sysinfo.totalfreeram;
38 stats.memory = scaleSize(a) + ' / ' + scaleSize(b) + ' <small>(' + (b / a * 100.0).toFixed(2) + '%)</small>';
39 if (sysinfo.totalswap > 0) {
40 a = sysinfo.totalswap;
42 stats.swap = scaleSize(a) + ' / ' + scaleSize(b) + ' <small>(' + (b / a * 100.0).toFixed(2) + '%)</small>';
46 stats.time = '<% time(); %>';
47 stats.wanup = '<% wanup(); %>' == '1';
48 stats.wanuptime = '<% link_uptime(); %>';
49 stats.wanlease = '<% dhcpc_time(); %>';
52 stats.dns = dns.join(', ');
54 stats.wanip = nvram.wan_ipaddr;
55 stats.wannetmask = nvram.wan_netmask;
56 stats.wangateway = nvram.wan_gateway_get;
57 if (stats.wangateway == '0.0.0.0' || stats.wangateway == '')
58 stats.wangateway = nvram.wan_gateway;
60 switch (nvram.wan_proto) {
64 stats.wanip = nvram.ppp_get_ip;
65 if (nvram.pptp_dhcp == '1') {
66 if (nvram.wan_ipaddr != '' && nvram.wan_ipaddr != '0.0.0.0' && nvram.wan_ipaddr != stats.wanip)
67 stats.wanip += ' <small>(DHCP: ' + nvram.wan_ipaddr + ')</small>';
68 if (nvram.wan_gateway != '' && nvram.wan_gateway != '0.0.0.0' && nvram.wan_gateway != stats.wangateway)
69 stats.wangateway += ' <small>(DHCP: ' + nvram.wan_gateway + ')</small>';
71 if (stats.wannetmask == '0.0.0.0')
72 stats.wannetmask = '255.255.255.255';
75 if (nvram.wan_proto == 'pptp')
76 stats.wangateway = nvram.pptp_server_ip;
81 stats.wanip = '0.0.0.0';
82 stats.wannetmask = '0.0.0.0';
83 stats.wangateway = '0.0.0.0';
88 stats.ip6_wan = ((typeof(sysinfo.ip6_wan) != 'undefined') ? sysinfo.ip6_wan : '') + '';
89 stats.ip6_lan = ((typeof(sysinfo.ip6_lan) != 'undefined') ? sysinfo.ip6_lan : '') + ''
90 stats.ip6_lan_ll = ((typeof(sysinfo.ip6_lan_ll) != 'undefined') ? sysinfo.ip6_lan_ll : '') + ''
93 stats.wanstatus = '<% wanstatus(); %>';
94 if (stats.wanstatus != 'Connected') stats.wanstatus = '<b>' + stats.wanstatus + '</b>';
97 stats.interference = [];
100 for (var uidx = 0; uidx < wl_ifaces.length; ++uidx) {
103 a = i = wlstats[uidx].channel * 1;
105 stats.channel.push('<a href="tools-survey.asp">' + ((i) ? i + '' : 'Auto') +
106 ((wlstats[uidx].mhz) ? ' - ' + (wlstats[uidx].mhz / 1000.0).toFixed(3) + ' <small>GHz</small>' : '') + '</a>' +
107 ((a < 0) ? ' <small>(scanning...)</small>' : ''));
108 stats.interference.push((wlstats[uidx].intf >= 0) ? ((wlstats[uidx].intf) ? 'Severe' : 'Acceptable') : '');
110 a = wlstats[uidx].nbw * 1;
111 wlstats[uidx].nbw = (a > 0) ? (a + ' <small>MHz</small>') : 'Auto';
113 if (wlstats[uidx].radio) {
114 a = wlstats[uidx].rate * 1;
116 wlstats[uidx].rate = Math.floor(a / 2) + ((a & 1) ? '.5' : '') + ' <small>Mbps</small>';
118 wlstats[uidx].rate = '-';
120 if (wlstats[uidx].client) {
121 if (wlstats[uidx].rssi == 0) a = 0;
122 else a = MAX(wlstats[uidx].rssi - wlstats[uidx].noise, 0);
123 stats.qual.push(a + ' <img src="bar' + MIN(MAX(Math.floor(a / 10), 1), 6) + '.gif">');
128 wlstats[uidx].noise += ' <small>dBm</small>';
129 wlstats[uidx].rssi += ' <small>dBm</small>';
132 wlstats[uidx].rate = '';
133 wlstats[uidx].noise = '';
134 wlstats[uidx].rssi = '';