summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-mod-admin-full
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2018-06-25 09:33:07 +0200
committerJo-Philipp Wich <jo@mein.io>2018-06-25 09:33:07 +0200
commitb79982e5df0864a0c3c410c71d3074e7d048ecf9 (patch)
tree499e3bcfe3f9ca32a584e702d57588901f454d1b /modules/luci-mod-admin-full
parentff55e7f6b5eb760c99f658eaab8267a4db7f0be3 (diff)
luci-mod-admin-full: fix average traffic calculation in realtime bandwidth
Fixes #1908. Suggested-by: "mgalyean" Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-mod-admin-full')
-rw-r--r--modules/luci-mod-admin-full/luasrc/view/admin_status/bandwidth.htm15
1 files changed, 5 insertions, 10 deletions
diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_status/bandwidth.htm b/modules/luci-mod-admin-full/luasrc/view/admin_status/bandwidth.htm
index f0ef5e7a2..b7594bfd4 100644
--- a/modules/luci-mod-admin-full/luasrc/view/admin_status/bandwidth.htm
+++ b/modules/luci-mod-admin-full/luasrc/view/admin_status/bandwidth.htm
@@ -202,18 +202,13 @@
data_rx_peak = Math.max(data_rx_peak, data_rx[i]);
data_tx_peak = Math.max(data_tx_peak, data_tx[i]);
- if (i > 0)
- {
- data_rx_avg = (data_rx_avg + data_rx[i]) / 2;
- data_tx_avg = (data_tx_avg + data_tx[i]) / 2;
- }
- else
- {
- data_rx_avg = data_rx[i];
- data_tx_avg = data_tx[i];
- }
+ data_rx_avg += data_rx[i];
+ data_tx_avg += data_tx[i];
}
+ data_rx_avg = (data_rx_avg / Math.max(data_rx.length, 1));
+ data_tx_avg = (data_tx_avg / Math.max(data_tx.length, 1));
+
/* remember current timestamp, calculate horizontal scale */
data_stamp = data[data.length-1][TIME];
data_scale = height / (data_max * 1.1);