BWM and static ARP optimizations
[tomato.git] / release / src / router / www / bwm-client.asp
blob5a3b474cee23a3b5d7167d6d4212e642487c5539
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 For use with Tomato Firmware only.
8 No part of this file may be used without permission.
9 -->
10 <html>
11 <head>
12 <meta http-equiv='content-type' content='text/html;charset=utf-8'>
13 <meta name='robots' content='noindex,nofollow'>
14 <title>[<% ident(); %>] Bandwidth: Real-Time Client Monitor</title>
15 <link rel='stylesheet' type='text/css' href='tomato.css'>
16 <% css(); %>
17 <script type='text/javascript' src='tomato.js'></script>
19 <!-- / / / -->
21 <style type='text/css'>
22 #txt {
23 width: 550px;
24 white-space: nowrap;
26 #bwm-controls {
27 text-align: right;
28 margin-right: 5px;
29 margin-top: 5px;
30 float: right;
31 visibility: hidden;
33 ul.tabs a,
34 #tabs a {
35 width: 140px;
36 height: 12px;
37 font-size: 9px;
39 </style>
41 <script type='text/javascript' src='debug.js'></script>
43 <script type='text/javascript' src='wireless.jsx?_http_id=<% nv(http_id); %>'></script>
44 <script type='text/javascript' src='bwm-common.js'></script>
46 <script type='text/javascript'>
47 // <% nvram("wan_ifname,lan_ifname,wl_ifname,wan_proto,wan_iface,web_svg,rstats_colors,bwm_client,dhcpd_static"); %>
49 // <% devlist(); %>
51 var cprefix = 'bwcm_r';
52 var updateInt = 2;
53 var updateDiv = updateInt;
54 var updateMaxL = 300;
55 var updateReTotal = 1;
56 var prev = [];
57 var debugTime = 0;
58 var avgMode = 0;
59 var wdog = null;
60 var wdogWarn = null;
62 var ref = new TomatoRefresh('update.cgi', 'exec=climon', updateInt);
64 ref.stop = function() {
65 this.timer.start(1000);
68 ref.refresh = function(text) {
69 var c, i, h, n, j, k, l;
71 watchdogReset();
73 ++updating;
74 try {
75 climon = null;
76 eval(text);
78 n = (new Date()).getTime();
79 if (this.timeExpect) {
80 if (debugTime) E('dtime').innerHTML = (this.timeExpect - n) + ' ' + ((this.timeExpect + 1000*updateInt) - n);
81 this.timeExpect += 1000*updateInt;
82 this.refreshTime = MAX(this.timeExpect - n, 500);
84 else {
85 this.timeExpect = n + 1000*updateInt;
88 for (i in climon) {
89 c = climon[i];
90 if ((p = prev[i]) != null) {
91 h = speed_history[i];
93 h.rx.splice(0, 1);
94 h.rx.push((c.rx < p.rx) ? (c.rx + (0xFFFFFFFF - p.rx)) : (c.rx - p.rx));
96 h.tx.splice(0, 1);
97 h.tx.push((c.tx < p.tx) ? (c.tx + (0xFFFFFFFF - p.tx)) : (c.tx - p.tx));
99 else if (!speed_history[i]) {
100 speed_history[i] = {};
101 h = speed_history[i];
102 h.rx = [];
103 h.tx = [];
104 for (j = 300; j > 0; --j) {
105 h.rx.push(0);
106 h.tx.push(0);
108 h.count = 0;
110 prev[i] = c;
112 loadData();
114 catch (ex) {
116 --updating;
119 function watchdog() {
120 watchdogReset();
121 ref.stop();
122 wdogWarn.style.display = '';
125 function watchdogReset() {
126 if (wdog) clearTimeout(wdog)
127 wdog = setTimeout(watchdog, 5000*updateInt);
128 wdogWarn.style.display = 'none';
131 function init() {
132 if (nvram.bwm_client.length > 0) {
133 E('sesdiv').style.display = '';
135 populateCache();
137 speed_history = [];
139 initCommon(2, 1, 1);
141 wdogWarn = E('warnwd');
142 watchdogReset();
144 ref.start();
147 </script>
149 </head>
150 <body onload='init()'>
151 <form>
152 <table id='container' cellspacing=0>
153 <tr><td colspan=2 id='header'>
154 <div class='title'>Tomato</div>
155 <div class='version'>Version <% version(); %></div>
156 </td></tr>
157 <tr id='body'><td id='navi'><script type='text/javascript'>navi()</script></td>
158 <td id='content'>
159 <div id='ident'><% ident(); %></div>
161 <!-- / / / -->
162 <script type='text/javascript'>
163 if (nvram.bwm_client.length < 1) {
164 W('<i>You need to <a href="basic-static.asp">configure</a> which LAN clients/devices should be monitored before coming back to this page.</i>');
166 </script>
167 <div id='sesdiv' style='display:none'>
169 <div id='rstats'>
170 <div id='tab-area'></div>
172 <script type='text/javascript'>
173 if (nvram.web_svg != '0') {
174 // without a div, Opera 9 moves svgdoc several pixels outside of <embed> (?)
175 W("<div style='border-top:1px solid #f0f0f0;border-bottom:1px solid #f0f0f0;visibility:hidden;padding:0;margin:0' id='graph'><embed src='bwm-graph.svg?<% version(); %>' style='width:760px;height:300px;margin:0;padding:0' type='image/svg+xml' pluginspage='http://www.adobe.com/svg/viewer/install/'></embed></div>");
177 </script>
179 <div id='bwm-controls'>
180 <small>(<script type='text/javascript'>W(5*updateInt);</script> minute window, <script type='text/javascript'>W(updateInt);</script> second interval)</small><br>
181 <br>
182 Avg:&nbsp;
183 <a href='javascript:switchAvg(1)' id='avg1'>Off</a>,
184 <a href='javascript:switchAvg(2)' id='avg2'>2x</a>,
185 <a href='javascript:switchAvg(4)' id='avg4'>4x</a>,
186 <a href='javascript:switchAvg(6)' id='avg6'>6x</a>,
187 <a href='javascript:switchAvg(8)' id='avg8'>8x</a><br>
188 Max:&nbsp;
189 <a href='javascript:switchScale(0)' id='scale0'>Uniform</a>,
190 <a href='javascript:switchScale(1)' id='scale1'>Per Client</a><br>
191 Display:&nbsp;
192 <a href='javascript:switchDraw(0)' id='draw0'>Solid</a>,
193 <a href='javascript:switchDraw(1)' id='draw1'>Line</a><br>
194 Color:&nbsp; <a href='javascript:switchColor()' id='drawcolor'>-</a><br>
195 <small><a href='javascript:switchColor(1)' id='drawrev'>[reverse]</a></small><br>
197 <br><br>
198 &nbsp; &raquo; <a href="basic-static.asp">Configure</a>
199 </div>
201 <br><br>
202 <table border=0 cellspacing=2 id='txt'>
203 <tr>
204 <td width='8%' align='right' valign='top'><b style='border-bottom:blue 1px solid' id='rx-name'>RX</b></td>
205 <td width='15%' align='right' valign='top'><span id='rx-current'></span></td>
206 <td width='8%' align='right' valign='top'><b>Avg</b></td>
207 <td width='15%' align='right' valign='top' id='rx-avg'></td>
208 <td width='8%' align='right' valign='top'><b>Peak</b></td>
209 <td width='15%' align='right' valign='top' id='rx-max'></td>
210 <td width='8%' align='right' valign='top'><b>Total</b></td>
211 <td width='14%' align='right' valign='top' id='rx-total'></td>
212 <td>&nbsp;</td>
213 </tr>
214 <tr>
215 <td width='8%' align='right' valign='top'><b style='border-bottom:blue 1px solid' id='tx-name'>TX</b></td>
216 <td width='15%' align='right' valign='top'><span id='tx-current'></span></td>
217 <td width='8%' align='right' valign='top'><b>Avg</b></td>
218 <td width='15%' align='right' valign='top' id='tx-avg'></td>
219 <td width='8%' align='right' valign='top'><b>Peak</b></td>
220 <td width='15%' align='right' valign='top' id='tx-max'></td>
221 <td width='8%' align='right' valign='top'><b>Total</b></td>
222 <td width='14%' align='right' valign='top' id='tx-total'></td>
223 <td>&nbsp;</td>
224 </tr>
225 </table>
226 </div>
227 <br>
228 <br>
230 <!-- / / / -->
232 </td></tr>
233 <tr><td id='footer' colspan=2>
234 <span id='warnwd' style='display:none'>Warning: 10 second timeout, restarting...&nbsp;</span>
235 <span id='dtime'></span>
236 <img src='spin.gif' id='refresh-spinner' onclick='javascript:debugTime=1'>
238 </div>
239 </td></tr>
240 </table>
241 </form>
242 </body>
243 </html>