1 <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML
4.0//EN'
>
4 Copyright (C) 2006-2010 Jonathan Zarate
5 http://www.polarcloud.com/tomato/
7 IP Traffic enhancements
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.
16 <meta http-equiv='content-type' content='text/html;charset=utf-
8'
>
17 <meta name='robots' content='noindex,nofollow'
>
18 <title>[<%
ident(); %>] IP Traffic: Last
24 Hours
</title>
19 <link rel='stylesheet' type='text/css' href='tomato.css'
>
21 <script type='text/javascript' src='tomato.js'
></script>
25 <style type='text/css'
>
46 <script type='text/javascript' src='debug.js'
></script>
48 <script type='text/javascript' src='wireless.jsx?_http_id=<%
nv(http_id
); %>'
></script>
49 <script type='text/javascript' src='bwm-common.js'
></script>
50 <script type='text/javascript' src='bwm-hist.js'
></script>
51 <script type='text/javascript' src='interfaces.js'
></script>
53 <script type='text/javascript'
>
55 // <% 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"); %>
59 var cprefix
= 'ipt_24';
61 var updateDiv
= updateInt
;
63 var updateReTotal
= 1;
68 var ipt_addr_shown
= [];
69 var ipt_addr_hidden
= [];
73 function showHours() {
74 if (hours
== lastHours
) return;
75 showSelectedOption('hr', lastHours
, hours
);
79 function switchHours(h
) {
80 if ((!svgReady
) || (updating
)) return;
83 updateMaxL
= (720 / 24) * hours
;
86 cookie
.set(cprefix
+ 'hrs', hours
);
89 var ref
= new TomatoRefresh('update.cgi', 'exec=ipt_bandwidth&arg0=speed');
91 ref
.refresh = function(text
) {
94 this.refreshTime
= 1500;
100 for (i
in speed_history
) {
101 if ((ipt_addr_hidden
.find(i
) == -1) && (ipt_addr_shown
.find(i
) == -1) && (i
!= '_next')) {
102 ipt_addr_shown
.push(i
);
103 var option
=document
.createElement("option");
105 if (hostnamecache
[i
] != null) {
106 option
.text
= hostnamecache
[i
] + ' (' + i
+ ')';
110 E('_f_ipt_addr_shown').add(option
,null);
111 speed_history
[i
].hide
= 0;
114 if (ipt_addr_hidden
.find(i
) != -1) {
115 speed_history
[i
].hide
= 1;
117 speed_history
[i
].hide
= 0;
122 E('rbusy').style
.display
= 'none';
125 this.refreshTime
= (fixInt(speed_history
._next
, 1, 120, 60) + 2) * 1000;
129 E('rbusy').style
.display
= '';
131 if (debugTime
) E('dtime').innerHTML
= (ymdText(new Date())) + ' ' + (this.refreshTime
/ 1000);
137 // alert('ex=' + ex);
143 ref
.showState = function() {
144 E('refresh-button').value
= this.running
? 'Stop' : 'Start';
147 ref
.toggleX = function() {
150 cookie
.set(cprefix
+ 'refresh', this.running
? 1 : 0);
153 ref
.initX = function() {
156 a
= fixInt(cookie
.get(cprefix
+ 'refresh'), 0, 1, 1);
158 ref
.refreshTime
= 100;
164 if (nvram
.cstats_enable
!= '1') return;
169 if ((c
= cookie
.get('ipt_addr_hidden')) != null) {
171 for (var i
= 0; i
< c
.length
; ++i
) {
172 if (c
[i
].trim() != '') {
173 ipt_addr_hidden
.push(c
[i
]);
174 var option
=document
.createElement("option");
176 if (hostnamecache
[c
[i
]] != null) {
177 option
.text
= hostnamecache
[c
[i
]] + ' (' + c
[i
] + ')';
181 E('_f_ipt_addr_hidden').add(option
,null);
187 // <% ipt_bandwidth("speed"); %>
189 for (i
in speed_history
) {
190 if ((ipt_addr_hidden
.find(i
) == -1) && (ipt_addr_shown
.find(i
) == -1) && ( i
!= '_next') && (i
.trim() != '')) {
191 ipt_addr_shown
.push(i
);
192 var option
=document
.createElement("option");
194 if (hostnamecache
[i
] != null) {
195 ii
= hostnamecache
[i
] + ' (' + i
+ ')';
199 E('_f_ipt_addr_shown').add(option
,null);
200 speed_history
[i
].hide
= 0;
202 if (ipt_addr_hidden
.find(i
) != -1) {
203 speed_history
[i
].hide
= 1;
205 speed_history
[i
].hide
= 0;
211 // speed_history = {};
215 if (typeof(speed_history
) == 'undefined') {
218 E('rbusy').style
.display
= '';
221 hours
= fixInt(cookie
.get(cprefix
+ 'hrs'), 1, 24, 24);
222 updateMaxL
= (720 / 24) * hours
;
227 verifyFields(null,1);
229 var theRules
= document
.styleSheets
[2].cssRules
;
230 switch (nvram
['cstats_labels']) {
231 case '1': // show hostnames only
232 theRules
[theRules
.length
-1].style
.cssText
= 'width: 140px; font-weight:bold;';
234 // document.styleSheets[2].deleteRule(theRules.length - 1);
237 case '2': // show IPs only
238 theRules
[theRules
.length
-1].style
.cssText
= 'width: 140px; font-weight:bold;';
240 case '0': // show hostnames + IPs
243 // theRules[theRules.length-1].style.cssText = 'width: 140px; height: 12px; font-size: 9px;';
251 function verifyFields(focused
, quiet
) {
252 var changed_addr_hidden
= 0;
253 if (focused
!= null) {
254 if (focused
.id
== '_f_ipt_addr_shown') {
255 ipt_addr_shown
.remove(focused
.options
[focused
.selectedIndex
].value
);
256 ipt_addr_hidden
.push(focused
.options
[focused
.selectedIndex
].value
);
257 var option
=document
.createElement("option");
258 option
.text
=focused
.options
[focused
.selectedIndex
].text
;
259 option
.value
=focused
.options
[focused
.selectedIndex
].value
;
260 E('_f_ipt_addr_shown').remove(focused
.selectedIndex
);
261 E('_f_ipt_addr_shown').selectedIndex
=0;
262 E('_f_ipt_addr_hidden').add(option
,null);
263 changed_addr_hidden
= 1;
266 if (focused
.id
== '_f_ipt_addr_hidden') {
267 ipt_addr_hidden
.remove(focused
.options
[focused
.selectedIndex
].value
);
268 ipt_addr_shown
.push(focused
.options
[focused
.selectedIndex
].value
);
269 var option
=document
.createElement("option");
270 option
.text
=focused
.options
[focused
.selectedIndex
].text
;
271 option
.value
=focused
.options
[focused
.selectedIndex
].value
;
272 E('_f_ipt_addr_hidden').remove(focused
.selectedIndex
);
273 E('_f_ipt_addr_hidden').selectedIndex
=0;
274 E('_f_ipt_addr_shown').add(option
,null);
275 changed_addr_hidden
= 1;
277 if (changed_addr_hidden
== 1) {
278 cookie
.set('ipt_addr_hidden', ipt_addr_hidden
.join(','), 1);
289 if (E('_f_ipt_addr_hidden').length
< 2) {
290 E('_f_ipt_addr_hidden').disabled
= 1;
292 E('_f_ipt_addr_hidden').disabled
= 0;
295 if (E('_f_ipt_addr_shown').length
< 2) {
296 E('_f_ipt_addr_shown').disabled
= 1;
298 E('_f_ipt_addr_shown').disabled
= 0;
306 <body onload='init()'
>
308 <table id='container' cellspacing=
0>
309 <tr><td colspan=
2 id='header'
>
310 <div class='title'
>Tomato
</div>
311 <div class='version'
>Version <%
version(); %></div>
313 <tr id='body'
><td id='navi'
><script type='text/javascript'
>navi()</script></td>
315 <div id='ident'
><%
ident(); %></div>
320 <div id='tab-area'
></div>
322 <script type='text/javascript'
>
323 if ((nvram
.web_svg
!= '0') && (nvram
.cstats_enable
== '1')) {
324 // without a div, Opera 9 moves svgdoc several pixels outside of <embed> (?)
325 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>");
329 <div id='bwm-controls'
>
330 <small>(
2 minute interval)
</small><br>
333 <a href='javascript:switchHours(
1);' id='hr1'
>1</a>,
334 <a href='javascript:switchHours(
2);' id='hr2'
>2</a>,
335 <a href='javascript:switchHours(
4);' id='hr4'
>4</a>,
336 <a href='javascript:switchHours(
6);' id='hr6'
>6</a>,
337 <a href='javascript:switchHours(
12);' id='hr12'
>12</a>,
338 <a href='javascript:switchHours(
18);' id='hr18'
>18</a>,
339 <a href='javascript:switchHours(
24);' id='hr24'
>24</a><br>
341 <a href='javascript:switchAvg(
1)' id='avg1'
>Off
</a>,
342 <a href='javascript:switchAvg(
2)' id='avg2'
>2x
</a>,
343 <a href='javascript:switchAvg(
4)' id='avg4'
>4x
</a>,
344 <a href='javascript:switchAvg(
6)' id='avg6'
>6x
</a>,
345 <a href='javascript:switchAvg(
8)' id='avg8'
>8x
</a><br>
347 <a href='javascript:switchScale(
0)' id='scale0'
>Uniform
</a>,
348 <a href='javascript:switchScale(
1)' id='scale1'
>Per Address
</a><br>
350 <a href='javascript:switchDraw(
0)' id='draw0'
>Solid
</a>,
351 <a href='javascript:switchDraw(
1)' id='draw1'
>Line
</a><br>
352 Color:
<a href='javascript:switchColor()' id='drawcolor'
>-
</a><br>
353 <small><a href='javascript:switchColor(
1)' id='drawrev'
>[reverse]
</a></small><br>
355 » <a href=
"admin-iptraffic.asp">Configure
</a>
359 <table border=
0 cellspacing=
2 id='txt'
>
361 <td width='
8%' align='right' valign='top'
><b style='border-bottom:blue
1px solid' id='rx-name'
>RX
</b></td>
362 <td width='
15%' align='right' valign='top'
><span id='rx-current'
></span></td>
363 <td width='
8%' align='right' valign='top'
><b>Avg
</b></td>
364 <td width='
15%' align='right' valign='top' id='rx-avg'
></td>
365 <td width='
8%' align='right' valign='top'
><b>Peak
</b></td>
366 <td width='
15%' align='right' valign='top' id='rx-max'
></td>
367 <td width='
8%' align='right' valign='top'
><b>Total
</b></td>
368 <td width='
14%' align='right' valign='top' id='rx-total'
></td>
372 <td width='
8%' align='right' valign='top'
><b style='border-bottom:blue
1px solid' id='tx-name'
>TX
</b></td>
373 <td width='
15%' align='right' valign='top'
><span id='tx-current'
></span></td>
374 <td width='
8%' align='right' valign='top'
><b>Avg
</b></td>
375 <td width='
15%' align='right' valign='top' id='tx-avg'
></td>
376 <td width='
8%' align='right' valign='top'
><b>Peak
</b></td>
377 <td width='
15%' align='right' valign='top' id='tx-max'
></td>
378 <td width='
8%' align='right' valign='top'
><b>Total
</b></td>
379 <td width='
14%' align='right' valign='top' id='tx-total'
></td>
389 <script type='text/javascript'
>
390 createFieldTable('', [
391 { 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>' },
392 { title
: 'Hidden addresses', name
: 'f_ipt_addr_hidden', type
: 'select', options
: [[0,'Select']], suffix
: ' <small>(Click/select to show it again)</small>' }
403 <script type='text/javascript'
>
404 if (nvram
.cstats_enable
!= '1') {
405 W('<div class="note-disabled">IP Traffic monitoring disabled.</b><br><br><a href="admin-iptraffic.asp">Enable »</a><div>');
406 E('cstats').style
.display
= 'none';
408 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>');
415 <tr><td id='footer' colspan=
2>
416 <span id='dtime'
></span>
417 <img src='spin.gif' id='refresh-spinner' onclick='debugTime=
1'
>
418 <input type='button' value='Refresh' id='refresh-button' onclick='ref.toggleX()'
>