1 <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML
4.0//EN'
>
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.
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'
>
17 <script type='text/javascript' src='tomato.js'
></script>
21 <style type='text/css'
>
42 <script type='text/javascript' src='debug.js'
></script>
44 <script type='text/javascript' src='wireless.jsx?_http_id=<%
nv(http_id
); %>'
></script>
45 <script type='text/javascript' src='bwm-common.js'
></script>
46 <script type='text/javascript' src='interfaces.js'
></script>
48 <script type='text/javascript'
>
49 // <% nvram("wan_ifname,lan_ifname,wl_ifname,wan_proto,wan_iface,web_svg,cstats_enable,cstats_colors,dhcpd_static,lan_ipaddr,lan_netmask,lan1_ipaddr,lan1_netmask,lan2_ipaddr,lan2_netmask,lan3_ipaddr,lan3_netmask,cstats_labels"); %>
55 var updateDiv
= updateInt
;
57 var updateReTotal
= 1;
64 var ipt_addr_shown
= [];
65 var ipt_addr_hidden
= [];
69 var ref
= new TomatoRefresh('update.cgi', 'exec=iptmon', updateInt
);
71 ref
.stop = function() {
72 this.timer
.start(1000);
75 ref
.refresh = function(text
) {
76 var c
, i
, h
, n
, j
, k
, l
;
85 n
= (new Date()).getTime();
86 if (this.timeExpect
) {
87 if (debugTime
) E('dtime').innerHTML
= (this.timeExpect
- n
) + ' ' + ((this.timeExpect
+ 1000*updateInt
) - n
);
88 this.timeExpect
+= 1000*updateInt
;
89 this.refreshTime
= MAX(this.timeExpect
- n
, 500);
92 this.timeExpect
= n
+ 1000*updateInt
;
97 if ((p
= prev
[i
]) != null) {
101 h
.rx
.push((c
.rx
< p
.rx
) ? (c
.rx
+ (0xFFFFFFFF - p
.rx
)) : (c
.rx
- p
.rx
));
104 h
.tx
.push((c
.tx
< p
.tx
) ? (c
.tx
+ (0xFFFFFFFF - p
.tx
)) : (c
.tx
- p
.tx
));
106 else if (!speed_history
[i
]) {
107 speed_history
[i
] = {};
108 h
= speed_history
[i
];
111 for (j
= 300; j
> 0; --j
) {
120 if ((ipt_addr_hidden
.find(i
) == -1) && (ipt_addr_shown
.find(i
) == -1) && (i
.trim() != '')) {
121 ipt_addr_shown
.push(i
);
122 var option
=document
.createElement("option");
124 if (hostnamecache
[i
] != null) {
125 option
.text
= hostnamecache
[i
] + ' (' + i
+ ')';
129 E('_f_ipt_addr_shown').add(option
,null);
132 if (ipt_addr_hidden
.find(i
) != -1) {
133 speed_history
[i
].hide
= 1;
135 speed_history
[i
].hide
= 0;
138 verifyFields(null,1);
145 // alert('ex=' + ex);
151 function watchdog() {
154 wdogWarn
.style
.display
= '';
157 function watchdogReset() {
158 if (wdog
) clearTimeout(wdog
)
159 wdog
= setTimeout(watchdog
, 5000*updateInt
);
160 wdogWarn
.style
.display
= 'none';
164 if (nvram
.cstats_enable
!= '1') return;
172 wdogWarn
= E('warnwd');
176 if ((c
= cookie
.get('ipt_addr_hidden')) != null) {
178 for (var i
= 0; i
< c
.length
; ++i
) {
179 if (c
[i
].trim() != '') {
180 ipt_addr_hidden
.push(c
[i
]);
181 var option
=document
.createElement("option");
183 if (hostnamecache
[c
[i
]] != null) {
184 option
.text
= hostnamecache
[c
[i
]] + ' (' + c
[i
] + ')';
188 E('_f_ipt_addr_hidden').add(option
,null);
193 verifyFields(null,1);
195 var theRules
= document
.styleSheets
[document
.styleSheets
.length
-1].cssRules
;
196 switch (nvram
['cstats_labels']) {
197 case '1': // show hostnames only
198 theRules
[theRules
.length
-1].style
.cssText
= 'width: 140px; font-weight:bold;';
200 // document.styleSheets[2].deleteRule(theRules.length - 1);
203 case '2': // show IPs only
204 theRules
[theRules
.length
-1].style
.cssText
= 'width: 140px; font-weight:bold;';
206 case '0': // show hostnames + IPs
209 // theRules[theRules.length-1].style.cssText = 'width: 140px; height: 12px; font-size: 9px;';
217 function verifyFields(focused
, quiet
) {
218 var changed_addr_hidden
= 0;
219 if (focused
!= null) {
220 if (focused
.id
== '_f_ipt_addr_shown') {
221 ipt_addr_shown
.remove(focused
.options
[focused
.selectedIndex
].value
);
222 ipt_addr_hidden
.push(focused
.options
[focused
.selectedIndex
].value
);
223 var option
=document
.createElement("option");
224 option
.text
=focused
.options
[focused
.selectedIndex
].text
;
225 option
.value
=focused
.options
[focused
.selectedIndex
].value
;
226 E('_f_ipt_addr_shown').remove(focused
.selectedIndex
);
227 E('_f_ipt_addr_shown').selectedIndex
=0;
228 E('_f_ipt_addr_hidden').add(option
,null);
229 changed_addr_hidden
= 1;
232 if (focused
.id
== '_f_ipt_addr_hidden') {
233 ipt_addr_hidden
.remove(focused
.options
[focused
.selectedIndex
].value
);
234 ipt_addr_shown
.push(focused
.options
[focused
.selectedIndex
].value
);
235 var option
=document
.createElement("option");
236 option
.text
=focused
.options
[focused
.selectedIndex
].text
;
237 option
.value
=focused
.options
[focused
.selectedIndex
].value
;
238 E('_f_ipt_addr_hidden').remove(focused
.selectedIndex
);
239 E('_f_ipt_addr_hidden').selectedIndex
=0;
240 E('_f_ipt_addr_shown').add(option
,null);
241 changed_addr_hidden
= 1;
243 if (changed_addr_hidden
== 1) {
244 cookie
.set('ipt_addr_hidden', ipt_addr_hidden
.join(','), 1);
248 if (E('_f_ipt_addr_hidden').length
< 2) {
249 E('_f_ipt_addr_hidden').disabled
= 1;
251 E('_f_ipt_addr_hidden').disabled
= 0;
254 if (E('_f_ipt_addr_shown').length
< 2) {
255 E('_f_ipt_addr_shown').disabled
= 1;
257 E('_f_ipt_addr_shown').disabled
= 0;
265 <body onload='init()'
>
267 <table id='container' cellspacing=
0>
268 <tr><td colspan=
2 id='header'
>
269 <div class='title'
>Tomato
</div>
270 <div class='version'
>Version <%
version(); %></div>
272 <tr id='body'
><td id='navi'
><script type='text/javascript'
>navi()</script></td>
274 <div id='ident'
><%
ident(); %></div>
278 <div id='tab-area'
></div>
280 <script type='text/javascript'
>
281 if ((nvram
.web_svg
!= '0') && (nvram
.cstats_enable
== '1')) {
282 // without a div, Opera 9 moves svgdoc several pixels outside of <embed> (?)
283 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>");
287 <div id='bwm-controls'
>
288 <small>(
<script type='text/javascript'
>W(5*updateInt
);</script> minute window,
<script type='text/javascript'
>W(updateInt);
</script> second interval)
</small><br>
291 <a href='javascript:switchAvg(
1)' id='avg1'
>Off
</a>,
292 <a href='javascript:switchAvg(
2)' id='avg2'
>2x
</a>,
293 <a href='javascript:switchAvg(
4)' id='avg4'
>4x
</a>,
294 <a href='javascript:switchAvg(
6)' id='avg6'
>6x
</a>,
295 <a href='javascript:switchAvg(
8)' id='avg8'
>8x
</a><br>
297 <a href='javascript:switchScale(
0)' id='scale0'
>Uniform
</a>,
298 <a href='javascript:switchScale(
1)' id='scale1'
>Per Address
</a><br>
300 <a href='javascript:switchDraw(
0)' id='draw0'
>Solid
</a>,
301 <a href='javascript:switchDraw(
1)' id='draw1'
>Line
</a><br>
302 Color:
<a href='javascript:switchColor()' id='drawcolor'
>-
</a><br>
303 <small><a href='javascript:switchColor(
1)' id='drawrev'
>[reverse]
</a></small><br>
306 » <a href=
"admin-iptraffic.asp">Configure
</a>
310 <table border=
0 cellspacing=
2 id='txt'
>
312 <td width='
8%' align='right' valign='top'
><b style='border-bottom:blue
1px solid' id='rx-name'
>RX
</b></td>
313 <td width='
15%' align='right' valign='top'
><span id='rx-current'
></span></td>
314 <td width='
8%' align='right' valign='top'
><b>Avg
</b></td>
315 <td width='
15%' align='right' valign='top' id='rx-avg'
></td>
316 <td width='
8%' align='right' valign='top'
><b>Peak
</b></td>
317 <td width='
15%' align='right' valign='top' id='rx-max'
></td>
318 <td width='
8%' align='right' valign='top'
><b>Total
</b></td>
319 <td width='
14%' align='right' valign='top' id='rx-total'
></td>
323 <td width='
8%' align='right' valign='top'
><b style='border-bottom:blue
1px solid' id='tx-name'
>TX
</b></td>
324 <td width='
15%' align='right' valign='top'
><span id='tx-current'
></span></td>
325 <td width='
8%' align='right' valign='top'
><b>Avg
</b></td>
326 <td width='
15%' align='right' valign='top' id='tx-avg'
></td>
327 <td width='
8%' align='right' valign='top'
><b>Peak
</b></td>
328 <td width='
15%' align='right' valign='top' id='tx-max'
></td>
329 <td width='
8%' align='right' valign='top'
><b>Total
</b></td>
330 <td width='
14%' align='right' valign='top' id='tx-total'
></td>
340 <script type='text/javascript'
>
341 createFieldTable('', [
342 { title
: 'IPs currently on graphic', name
: 'f_ipt_addr_shown', type
: 'select', options
: [[0,'Select']], suffix
: ' <small>(Click/select a device from this list to hide it)</small>' },
343 { title
: 'Hidden addresses', name
: 'f_ipt_addr_hidden', type
: 'select', options
: [[0,'Select']], suffix
: ' <small>(Click/select to show it again)</small>' }
353 <script type='text/javascript'
>
354 if (nvram
.cstats_enable
!= '1') {
355 W('<div class="note-disabled">IP Traffic monitoring disabled.</b><br><br><a href="admin-iptraffic.asp">Enable »</a><div>');
356 E('cstats').style
.display
= 'none';
358 W('<div class="note-warning" style="display:none" id="rbusy">The cstats program is not responding or is busy. Try reloading after a few seconds.</div>');
365 <tr><td id='footer' colspan=
2>
366 <span id='warnwd' style='display:none'
>Warning:
10 second timeout, restarting...
</span>
367 <span id='dtime'
></span>
368 <img src='spin.gif' id='refresh-spinner' onclick='javascript:debugTime=
1'
>