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"); %>
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') {
165 E('refresh-button').disabled
= 1;
172 if ((c
= cookie
.get('ipt_addr_hidden')) != null) {
174 for (var i
= 0; i
< c
.length
; ++i
) {
175 if (c
[i
].trim() != '') {
176 ipt_addr_hidden
.push(c
[i
]);
177 var option
=document
.createElement("option");
179 if (hostnamecache
[c
[i
]] != null) {
180 option
.text
= hostnamecache
[c
[i
]] + ' (' + c
[i
] + ')';
184 E('_f_ipt_addr_hidden').add(option
,null);
190 // <% ipt_bandwidth("speed"); %>
192 for (i
in speed_history
) {
193 if ((ipt_addr_hidden
.find(i
) == -1) && (ipt_addr_shown
.find(i
) == -1) && ( i
!= '_next') && (i
.trim() != '')) {
194 ipt_addr_shown
.push(i
);
195 var option
=document
.createElement("option");
197 if (hostnamecache
[i
] != null) {
198 ii
= hostnamecache
[i
] + ' (' + i
+ ')';
202 E('_f_ipt_addr_shown').add(option
,null);
203 speed_history
[i
].hide
= 0;
205 if (ipt_addr_hidden
.find(i
) != -1) {
206 speed_history
[i
].hide
= 1;
208 speed_history
[i
].hide
= 0;
214 // speed_history = {};
218 if (typeof(speed_history
) == 'undefined') {
221 E('rbusy').style
.display
= '';
224 hours
= fixInt(cookie
.get(cprefix
+ 'hrs'), 1, 24, 24);
225 updateMaxL
= (720 / 24) * hours
;
230 verifyFields(null,1);
232 var theRules
= document
.styleSheets
[document
.styleSheets
.length
-1].cssRules
;
233 switch (nvram
['cstats_labels']) {
234 case '1': // show hostnames only
235 theRules
[theRules
.length
-1].style
.cssText
= 'width: 140px; font-weight:bold;';
237 // document.styleSheets[2].deleteRule(theRules.length - 1);
240 case '2': // show IPs only
241 theRules
[theRules
.length
-1].style
.cssText
= 'width: 140px; font-weight:bold;';
243 case '0': // show hostnames + IPs
246 // theRules[theRules.length-1].style.cssText = 'width: 140px; height: 12px; font-size: 9px;';
254 function verifyFields(focused
, quiet
) {
255 var changed_addr_hidden
= 0;
256 if (focused
!= null) {
257 if (focused
.id
== '_f_ipt_addr_shown') {
258 ipt_addr_shown
.remove(focused
.options
[focused
.selectedIndex
].value
);
259 ipt_addr_hidden
.push(focused
.options
[focused
.selectedIndex
].value
);
260 var option
=document
.createElement("option");
261 option
.text
=focused
.options
[focused
.selectedIndex
].text
;
262 option
.value
=focused
.options
[focused
.selectedIndex
].value
;
263 E('_f_ipt_addr_shown').remove(focused
.selectedIndex
);
264 E('_f_ipt_addr_shown').selectedIndex
=0;
265 E('_f_ipt_addr_hidden').add(option
,null);
266 changed_addr_hidden
= 1;
269 if (focused
.id
== '_f_ipt_addr_hidden') {
270 ipt_addr_hidden
.remove(focused
.options
[focused
.selectedIndex
].value
);
271 ipt_addr_shown
.push(focused
.options
[focused
.selectedIndex
].value
);
272 var option
=document
.createElement("option");
273 option
.text
=focused
.options
[focused
.selectedIndex
].text
;
274 option
.value
=focused
.options
[focused
.selectedIndex
].value
;
275 E('_f_ipt_addr_hidden').remove(focused
.selectedIndex
);
276 E('_f_ipt_addr_hidden').selectedIndex
=0;
277 E('_f_ipt_addr_shown').add(option
,null);
278 changed_addr_hidden
= 1;
280 if (changed_addr_hidden
== 1) {
281 cookie
.set('ipt_addr_hidden', ipt_addr_hidden
.join(','), 1);
292 if (E('_f_ipt_addr_hidden').length
< 2) {
293 E('_f_ipt_addr_hidden').disabled
= 1;
295 E('_f_ipt_addr_hidden').disabled
= 0;
298 if (E('_f_ipt_addr_shown').length
< 2) {
299 E('_f_ipt_addr_shown').disabled
= 1;
301 E('_f_ipt_addr_shown').disabled
= 0;
309 <body onload='init()'
>
311 <table id='container' cellspacing=
0>
312 <tr><td colspan=
2 id='header'
>
313 <div class='title'
>Tomato
</div>
314 <div class='version'
>Version <%
version(); %></div>
316 <tr id='body'
><td id='navi'
><script type='text/javascript'
>navi()</script></td>
318 <div id='ident'
><%
ident(); %></div>
323 <div id='tab-area'
></div>
325 <script type='text/javascript'
>
326 if ((nvram
.web_svg
!= '0') && (nvram
.cstats_enable
== '1')) {
327 // without a div, Opera 9 moves svgdoc several pixels outside of <embed> (?)
328 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>");
332 <div id='bwm-controls'
>
333 <small>(
2 minute interval)
</small><br>
336 <a href='javascript:switchHours(
1);' id='hr1'
>1</a>,
337 <a href='javascript:switchHours(
2);' id='hr2'
>2</a>,
338 <a href='javascript:switchHours(
4);' id='hr4'
>4</a>,
339 <a href='javascript:switchHours(
6);' id='hr6'
>6</a>,
340 <a href='javascript:switchHours(
12);' id='hr12'
>12</a>,
341 <a href='javascript:switchHours(
18);' id='hr18'
>18</a>,
342 <a href='javascript:switchHours(
24);' id='hr24'
>24</a><br>
344 <a href='javascript:switchAvg(
1)' id='avg1'
>Off
</a>,
345 <a href='javascript:switchAvg(
2)' id='avg2'
>2x
</a>,
346 <a href='javascript:switchAvg(
4)' id='avg4'
>4x
</a>,
347 <a href='javascript:switchAvg(
6)' id='avg6'
>6x
</a>,
348 <a href='javascript:switchAvg(
8)' id='avg8'
>8x
</a><br>
350 <a href='javascript:switchScale(
0)' id='scale0'
>Uniform
</a>,
351 <a href='javascript:switchScale(
1)' id='scale1'
>Per Address
</a><br>
353 <a href='javascript:switchDraw(
0)' id='draw0'
>Solid
</a>,
354 <a href='javascript:switchDraw(
1)' id='draw1'
>Line
</a><br>
355 Color:
<a href='javascript:switchColor()' id='drawcolor'
>-
</a><br>
356 <small><a href='javascript:switchColor(
1)' id='drawrev'
>[reverse]
</a></small><br>
358 » <a href=
"admin-iptraffic.asp">Configure
</a>
362 <table border=
0 cellspacing=
2 id='txt'
>
364 <td width='
8%' align='right' valign='top'
><b style='border-bottom:blue
1px solid' id='rx-name'
>RX
</b></td>
365 <td width='
15%' align='right' valign='top'
><span id='rx-current'
></span></td>
366 <td width='
8%' align='right' valign='top'
><b>Avg
</b></td>
367 <td width='
15%' align='right' valign='top' id='rx-avg'
></td>
368 <td width='
8%' align='right' valign='top'
><b>Peak
</b></td>
369 <td width='
15%' align='right' valign='top' id='rx-max'
></td>
370 <td width='
8%' align='right' valign='top'
><b>Total
</b></td>
371 <td width='
14%' align='right' valign='top' id='rx-total'
></td>
375 <td width='
8%' align='right' valign='top'
><b style='border-bottom:blue
1px solid' id='tx-name'
>TX
</b></td>
376 <td width='
15%' align='right' valign='top'
><span id='tx-current'
></span></td>
377 <td width='
8%' align='right' valign='top'
><b>Avg
</b></td>
378 <td width='
15%' align='right' valign='top' id='tx-avg'
></td>
379 <td width='
8%' align='right' valign='top'
><b>Peak
</b></td>
380 <td width='
15%' align='right' valign='top' id='tx-max'
></td>
381 <td width='
8%' align='right' valign='top'
><b>Total
</b></td>
382 <td width='
14%' align='right' valign='top' id='tx-total'
></td>
392 <script type='text/javascript'
>
393 createFieldTable('', [
394 { 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>' },
395 { title
: 'Hidden addresses', name
: 'f_ipt_addr_hidden', type
: 'select', options
: [[0,'Select']], suffix
: ' <small>(Click/select to show it again)</small>' }
407 <script type='text/javascript'
>
408 if (nvram
.cstats_enable
!= '1') {
409 W('<div class="note-disabled">IP Traffic monitoring disabled.</b><br><br><a href="admin-iptraffic.asp">Enable »</a><div>');
410 E('cstats').style
.display
= 'none';
412 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>');
419 <tr><td id='footer' colspan=
2>
420 <span id='dtime'
></span>
421 <img src='spin.gif' id='refresh-spinner' onclick='debugTime=
1'
>
422 <input type='button' value='Refresh' id='refresh-button' onclick='ref.toggleX()'
>