diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2010-11-29 14:14:17 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2010-11-29 14:14:17 +0000 |
commit | 143131ea77822c3fa84a093f796aae1ee46120dc (patch) | |
tree | ec92ca49d4a15aada620f61c1923e9a3638b574c /modules/admin-full/luasrc | |
parent | a3207ded531e9c1288f58642922fd0686aea8a8e (diff) |
modules/admin-full: track non-tcp or udp connections, use /proc/net/nf_conntrack on newer systems
Diffstat (limited to 'modules/admin-full/luasrc')
-rw-r--r-- | modules/admin-full/luasrc/view/admin_status/connections.htm | 105 |
1 files changed, 72 insertions, 33 deletions
diff --git a/modules/admin-full/luasrc/view/admin_status/connections.htm b/modules/admin-full/luasrc/view/admin_status/connections.htm index 991eb67610..eb48398527 100644 --- a/modules/admin-full/luasrc/view/admin_status/connections.htm +++ b/modules/admin-full/luasrc/view/admin_status/connections.htm @@ -19,9 +19,10 @@ $Id$ var bwxhr = new XHR(); var G; - var TIME = 0; - var UDP = 1; - var TCP = 2; + var TIME = 0; + var UDP = 1; + var TCP = 2; + var OTHER = 3; var width = 760; var height = 300; @@ -33,6 +34,7 @@ $Id$ var data_udp = [ ]; var data_tcp = [ ]; + var data_otr = [ ]; var line_udp; var line_tcp; @@ -41,13 +43,17 @@ $Id$ var label_50; var label_75; - var label_rx_cur; - var label_rx_avg; - var label_rx_peak; + var label_udp_cur; + var label_udp_avg; + var label_udp_peak; - var label_tx_cur; - var label_tx_avg; - var label_tx_peak; + var label_tcp_cur; + var label_tcp_avg; + var label_tcp_peak; + + var label_otr_cur; + var label_otr_avg; + var label_otr_peak; var label_scale; @@ -62,9 +68,11 @@ $Id$ var data_udp_avg = 0; var data_tcp_avg = 0; + var data_otr_avg = 0; var data_udp_peak = 0; var data_tcp_peak = 0; + var data_otr_peak = 0; for (var i = data_stamp ? 0 : 1; i < data.length; i++) { @@ -74,30 +82,36 @@ $Id$ data_udp.push(data[i][UDP]); data_tcp.push(data[i][TCP]); + data_otr.push(data[i][OTHER]); } /* cut off outdated entries */ data_udp = data_udp.slice(data_udp.length - data_wanted, data_udp.length); data_tcp = data_tcp.slice(data_tcp.length - data_wanted, data_tcp.length); + data_otr = data_otr.slice(data_otr.length - data_wanted, data_otr.length); /* find peak */ for (var i = 0; i < data_udp.length; i++) { data_max = Math.max(data_max, data_udp[i]); data_max = Math.max(data_max, data_tcp[i]); + data_max = Math.max(data_max, data_otr[i]); data_udp_peak = Math.max(data_udp_peak, data_udp[i]); data_tcp_peak = Math.max(data_tcp_peak, data_tcp[i]); + data_otr_peak = Math.max(data_otr_peak, data_otr[i]); if (i > 0) { data_udp_avg = (data_udp_avg + data_udp[i]) / 2; data_tcp_avg = (data_tcp_avg + data_tcp[i]) / 2; + data_otr_avg = (data_otr_avg + data_otr[i]) / 2; } else { data_udp_avg = data_udp[i]; data_tcp_avg = data_tcp[i]; + data_otr_avg = data_otr[i]; } } @@ -107,42 +121,51 @@ $Id$ /* plot data */ - var pt_rx = '0,' + height; - var pt_tx = '0,' + height; + var pt_udp = '0,' + height; + var pt_tcp = '0,' + height; + var pt_otr = '0,' + height; - var y_rx = 0; - var y_tx = 0; + var y_udp = 0; + var y_tcp = 0; + var y_otr = 0; for (var i = 0; i < data_udp.length; i++) { var x = i * step; - y_rx = height - Math.floor(data_udp[i] * data_scale); - y_tx = height - Math.floor(data_tcp[i] * data_scale); + y_udp = height - Math.floor(data_udp[i] * data_scale); + y_tcp = height - Math.floor(data_tcp[i] * data_scale); + y_otr = height - Math.floor(data_otr[i] * data_scale); - pt_rx += ' ' + x + ',' + y_rx; - pt_tx += ' ' + x + ',' + y_tx; + pt_udp += ' ' + x + ',' + y_udp; + pt_tcp += ' ' + x + ',' + y_tcp; + pt_otr += ' ' + x + ',' + y_otr; } - pt_rx += ' ' + width + ',' + y_rx + ' ' + width + ',' + height; - pt_tx += ' ' + width + ',' + y_tx + ' ' + width + ',' + height; + pt_udp += ' ' + width + ',' + y_udp + ' ' + width + ',' + height; + pt_tcp += ' ' + width + ',' + y_tcp + ' ' + width + ',' + height; + pt_otr += ' ' + width + ',' + y_otr + ' ' + width + ',' + height; - line_udp.setAttribute('points', pt_rx); - line_tcp.setAttribute('points', pt_tx); + line_udp.setAttribute('points', pt_udp); + line_tcp.setAttribute('points', pt_tcp); + line_otr.setAttribute('points', pt_otr); label_25.firstChild.data = Math.floor(1.1 * 0.25 * data_max); label_50.firstChild.data = Math.floor(1.1 * 0.50 * data_max); label_75.firstChild.data = Math.floor(1.1 * 0.75 * data_max); - label_rx_cur.innerHTML = Math.floor(data_udp[data_udp.length-1]); - label_tx_cur.innerHTML = Math.floor(data_tcp[data_tcp.length-1]); + label_udp_cur.innerHTML = Math.floor(data_udp[data_udp.length-1]); + label_tcp_cur.innerHTML = Math.floor(data_tcp[data_tcp.length-1]); + label_otr_cur.innerHTML = Math.floor(data_otr[data_otr.length-1]); - label_rx_avg.innerHTML = Math.floor(data_udp_avg); - label_tx_avg.innerHTML = Math.floor(data_tcp_avg); + label_udp_avg.innerHTML = Math.floor(data_udp_avg); + label_tcp_avg.innerHTML = Math.floor(data_tcp_avg); + label_otr_avg.innerHTML = Math.floor(data_otr_avg); - label_rx_peak.innerHTML = Math.floor(data_udp_peak); - label_tx_peak.innerHTML = Math.floor(data_tcp_peak); + label_udp_peak.innerHTML = Math.floor(data_udp_peak); + label_tcp_peak.innerHTML = Math.floor(data_tcp_peak); + label_otr_peak.innerHTML = Math.floor(data_otr_peak); /* reset timer */ window.setTimeout(update_graph, 1000); @@ -179,23 +202,29 @@ $Id$ { data_udp[i] = 0; data_tcp[i] = 0; + data_otr[i] = 0; } /* find svg elements */ line_udp = G.getElementById('udp'); line_tcp = G.getElementById('tcp'); + line_otr = G.getElementById('other'); label_25 = G.getElementById('label_25'); label_50 = G.getElementById('label_50'); label_75 = G.getElementById('label_75'); - label_rx_cur = document.getElementById('lb_udp_cur'); - label_rx_avg = document.getElementById('lb_udp_avg'); - label_rx_peak = document.getElementById('lb_udp_peak'); + label_udp_cur = document.getElementById('lb_udp_cur'); + label_udp_avg = document.getElementById('lb_udp_avg'); + label_udp_peak = document.getElementById('lb_udp_peak'); + + label_tcp_cur = document.getElementById('lb_tcp_cur'); + label_tcp_avg = document.getElementById('lb_tcp_avg'); + label_tcp_peak = document.getElementById('lb_tcp_peak'); - label_tx_cur = document.getElementById('lb_tcp_cur'); - label_tx_avg = document.getElementById('lb_tcp_avg'); - label_tx_peak = document.getElementById('lb_tcp_peak'); + label_otr_cur = document.getElementById('lb_otr_cur'); + label_otr_avg = document.getElementById('lb_otr_avg'); + label_otr_peak = document.getElementById('lb_otr_peak'); label_scale = document.getElementById('scale'); @@ -256,6 +285,16 @@ $Id$ <td style="text-align:right; vertical-align:top"><strong><%:Peak:%></strong></td> <td id="lb_tcp_peak">0</td> </tr> + <tr> + <td style="text-align:right; vertical-align:top"><strong style="border-bottom:2px solid red"><%:Other:%></strong></td> + <td id="lb_otr_cur">0</td> + + <td style="text-align:right; vertical-align:top"><strong><%:Average:%></strong></td> + <td id="lb_otr_avg">0</td> + + <td style="text-align:right; vertical-align:top"><strong><%:Peak:%></strong></td> + <td id="lb_otr_peak">0</td> + </tr> </table> <%+footer%> |