[Libreoffice-commits] online.git: loleaflet/admin wsd/Admin.cpp wsd/AdminModel.hpp
nienzu (via logerrit)
logerrit at kemper.freedesktop.org
Wed Feb 26 09:53:43 UTC 2020
loleaflet/admin/adminAnalytics.html | 2
loleaflet/admin/src/AdminSocketAnalytics.js | 63 ++--------------------------
loleaflet/admin/src/Util.js | 2
wsd/Admin.cpp | 2
wsd/AdminModel.hpp | 4 -
5 files changed, 11 insertions(+), 62 deletions(-)
New commits:
commit 51c840249e8a7a094ae9594ab2aea13668c5d66b
Author: nienzu <tommy.wu at ossii.com.tw>
AuthorDate: Wed Feb 26 13:47:21 2020 +0800
Commit: Michael Meeks <michael.meeks at collabora.com>
CommitDate: Wed Feb 26 10:53:25 2020 +0100
tdf#130798 admin: Use original data to create network traffic graph
Instead of using the data of rolling average, using original data would
reflect the real network traffic.
Change-Id: I3f5a277b6ee8e7d760f5623eb4aae9f6c999e10f
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/89494
Tested-by: Michael Meeks <michael.meeks at collabora.com>
Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
diff --git a/loleaflet/admin/adminAnalytics.html b/loleaflet/admin/adminAnalytics.html
index 7f52c080f..7667c67df 100644
--- a/loleaflet/admin/adminAnalytics.html
+++ b/loleaflet/admin/adminAnalytics.html
@@ -30,7 +30,7 @@
host = 'ws://' + window.location.host + '%SERVICE_ROOT%/lool/adminws/'
}
- Admin.Analytics(host)
+ var socketAnalytics = Admin.Analytics(host);
</script>
<nav class="navbar navbar-inverse navbar-fixed-top">
diff --git a/loleaflet/admin/src/AdminSocketAnalytics.js b/loleaflet/admin/src/AdminSocketAnalytics.js
index fcc86d5d5..e965fc62e 100644
--- a/loleaflet/admin/src/AdminSocketAnalytics.js
+++ b/loleaflet/admin/src/AdminSocketAnalytics.js
@@ -13,9 +13,7 @@ var AdminSocketAnalytics = AdminSocketBase.extend({
_memStatsData: [],
_cpuStatsData: [],
_sentStatsData: [],
- _sentAvgStats: [],
_recvStatsData: [],
- _recvAvgStats: [],
_memStatsSize: 0,
_memStatsInterval: 0,
@@ -23,7 +21,6 @@ var AdminSocketAnalytics = AdminSocketBase.extend({
_cpuStatsSize: 0,
_cpuStatsInterval: 0,
- _netAvgSize: 10,
_netStatsSize: 0,
_netStatsInterval: 0,
@@ -48,10 +45,6 @@ var AdminSocketAnalytics = AdminSocketBase.extend({
this._sentStatsData = actualData;
else if (option === 'recv')
this._recvStatsData = actualData;
- else if (option === 'sent_avg')
- this._sentAvgStats = actualData;
- else if (option === 'recv_avg')
- this._recvAvgStats = actualData;
},
onSocketOpen: function() {
@@ -102,7 +95,7 @@ var AdminSocketAnalytics = AdminSocketBase.extend({
else if (option === 'cpu')
data = this._cpuStatsData;
else if (option === 'net')
- data = this._sentAvgStats.concat(this._recvAvgStats);
+ data = this._sentStatsData.concat(this._recvStatsData);
xScale = d3.scale.linear().range([this._graphMargins.left, this._graphWidth - this._graphMargins.right]).domain([d3.min(data, function(d) {
return d.time;
@@ -142,7 +135,7 @@ var AdminSocketAnalytics = AdminSocketBase.extend({
.y(function(d) {
return yScale(d.value);
})
- .interpolate('basis');
+ .interpolate('monotone');
if (option === 'mem') {
this._xMemScale = xScale;
@@ -264,14 +257,14 @@ var AdminSocketAnalytics = AdminSocketBase.extend({
else if (option === 'net') {
vis.append('svg:path')
- .attr('d', this._d3NetSentLine(this._sentAvgStats))
+ .attr('d', this._d3NetSentLine(this._sentStatsData))
.attr('class', 'lineSent')
.attr('stroke', 'red')
.attr('stroke-width', 1)
.attr('fill', 'none');
vis.append('svg:path')
- .attr('d', this._d3NetRecvLine(this._recvAvgStats))
+ .attr('d', this._d3NetRecvLine(this._recvStatsData))
.attr('class', 'lineRecv')
.attr('stroke', 'green')
.attr('stroke-width', 1)
@@ -294,16 +287,6 @@ var AdminSocketAnalytics = AdminSocketBase.extend({
graphName = '#CpuVisualisation';
line = 'line';
}
- else if (option === 'sent_avg') {
- size = this._netStatsSize - this._netAvgSize + 1;
- graphName = '#NetVisualisation';
- line = 'lineSent';
- }
- else if (option === 'recv_avg') {
- size = this._netStatsSize - this._netAvgSize + 1;
- graphName = '#NetVisualisation';
- line = 'lineRecv';
- }
else if (option === 'sent' || option === 'recv')
size = this._netStatsSize;
@@ -370,9 +353,9 @@ var AdminSocketAnalytics = AdminSocketBase.extend({
this._setUpAxis('net');
svg.select('.lineSent')
- .attr('d', this._d3NetSentLine(this._sentAvgStats));
+ .attr('d', this._d3NetSentLine(this._sentStatsData));
svg.select('.lineRecv')
- .attr('d', this._d3NetRecvLine(this._recvAvgStats));
+ .attr('d', this._d3NetRecvLine(this._recvStatsData));
svg.select('.x-axis')
.call(this._d3NetXAxis);
@@ -383,34 +366,6 @@ var AdminSocketAnalytics = AdminSocketBase.extend({
.call(this._d3NetYAxis);
},
- _updateAverage: function(option, reset) {
- var data, res, tempSum;
- if (option === 'sent') {
- data = this._sentStatsData;
- res = this._sentAvgStats;
- }
- else if (option === 'recv') {
- data = this._recvStatsData;
- res = this._recvAvgStats;
- }
-
- if (reset) {
- for (var i = 0; i <= this._netStatsSize - this._netAvgSize; i++) {
- tempSum = 0;
- for (var j = 0; j < this._netAvgSize; j++) {
- tempSum += data[i + j].value;
- }
- tempSum /= this._netAvgSize;
- res[i].value = tempSum;
- }
- }
- else {
- tempSum = res[res.length - 1].value + (data[data.length - 1].value - data[data.length - 1 - this._netAvgSize].value) / this._netAvgSize;
-
- this._addNewData(res, tempSum, 'sent_avg');
- }
- },
-
onSocketMessage: function(e) {
var textMsg;
if (typeof e.data === 'string') {
@@ -488,8 +443,6 @@ var AdminSocketAnalytics = AdminSocketBase.extend({
this._initStatsData('sent', this._netStatsSize, this._netStatsInterval, true);
this._initStatsData('recv', this._netStatsSize, this._netStatsInterval, true);
- this._initStatsData('sent_avg', this._netStatsSize - this._netAvgSize + 1, this._netStatsInterval, true);
- this._initStatsData('recv_avg', this._netStatsSize - this._netAvgSize + 1, this._netStatsInterval, true);
}
else if (textMsg.startsWith('mem_stats')) {
@@ -538,7 +491,6 @@ var AdminSocketAnalytics = AdminSocketBase.extend({
for (i = this._sentStatsData.length - 1, j = data.length - 1; i >= 0 && j >= 0; i--, j--) {
this._sentStatsData[i].value = parseInt(data[j]);
}
- this._updateAverage('sent', true);
if ($('#NetVisualisation').html() === '')
this._createGraph('net');
@@ -547,7 +499,6 @@ var AdminSocketAnalytics = AdminSocketBase.extend({
// this is a notification data; append to _sentStatsData
data = textMsg.trim();
this._addNewData(this._sentStatsData, parseInt(data), 'sent');
- this._updateAverage('sent', false);
this._updateNetGraph();
}
}
@@ -560,7 +511,6 @@ var AdminSocketAnalytics = AdminSocketBase.extend({
for (i = this._recvStatsData.length - 1, j = data.length - 1; i >= 0 && j >= 0; i--, j--) {
this._recvStatsData[i].value = parseInt(data[j]);
}
- this._updateAverage('recv', true);
if ($('#NetVisualisation').html() === '')
this._createGraph('net');
@@ -569,7 +519,6 @@ var AdminSocketAnalytics = AdminSocketBase.extend({
// this is a notification data; append to _recvStatsData
data = textMsg.trim();
this._addNewData(this._recvStatsData, parseInt(data), 'recv');
- this._updateAverage('recv', false);
this._updateNetGraph();
}
}
diff --git a/loleaflet/admin/src/Util.js b/loleaflet/admin/src/Util.js
index 9d8e2b179..6671ed458 100644
--- a/loleaflet/admin/src/Util.js
+++ b/loleaflet/admin/src/Util.js
@@ -16,7 +16,7 @@ var Util = Base.extend({
kbytes /= unit;
}
- return kbytes.toFixed(1) + ' ' + units[i];
+ return kbytes + ' ' + units[i];
},
humanizeSecs: function(secs) {
diff --git a/wsd/Admin.cpp b/wsd/Admin.cpp
index c4c48dfeb..db74b1535 100644
--- a/wsd/Admin.cpp
+++ b/wsd/Admin.cpp
@@ -45,7 +45,7 @@ using Poco::Net::HTTPResponse;
using Poco::Util::Application;
const int Admin::MinStatsIntervalMs = 50;
-const int Admin::DefStatsIntervalMs = 2500;
+const int Admin::DefStatsIntervalMs = 1000;
/// Process incoming websocket messages
void AdminSocketHandler::handleMessage(bool /* fin */, WSOpCode /* code */,
diff --git a/wsd/AdminModel.hpp b/wsd/AdminModel.hpp
index a3fb12fcc..f683cd45c 100644
--- a/wsd/AdminModel.hpp
+++ b/wsd/AdminModel.hpp
@@ -350,10 +350,10 @@ private:
unsigned _cpuStatsSize = 100;
std::list<unsigned> _sentStats;
- unsigned _sentStatsSize = 100;
+ unsigned _sentStatsSize = 200;
std::list<unsigned> _recvStats;
- unsigned _recvStatsSize = 100;
+ unsigned _recvStatsSize = 200;
uint64_t _sentBytesTotal;
uint64_t _recvBytesTotal;
More information about the Libreoffice-commits
mailing list