summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Moisseev <moiseev@mezonplus.ru>2017-02-12 14:23:55 +0300
committerAlexander Moisseev <moiseev@mezonplus.ru>2017-02-12 14:33:27 +0300
commitd0a206eb6e655f465f6584e69a00b4548a01e9df (patch)
tree653af948790839c5c7040acc00074f048b5700b3
parentc5e00c4bf1013a722b3cd313b1748e61bdf21d36 (diff)
downloadrspamd-d0a206eb6e655f465f6584e69a00b4548a01e9df.tar.gz
rspamd-d0a206eb6e655f465f6584e69a00b4548a01e9df.zip
[WebUI] Add neighbours RRD data consolidation
-rw-r--r--interface/js/app/graph.js66
-rw-r--r--interface/js/app/rspamd.js3
2 files changed, 56 insertions, 13 deletions
diff --git a/interface/js/app/graph.js b/interface/js/app/graph.js
index 4ab3e2c13..9f8043958 100644
--- a/interface/js/app/graph.js
+++ b/interface/js/app/graph.js
@@ -151,6 +151,21 @@ function($, D3Evolution, unused) {
var interface = {};
interface.draw = function(rspamd, graphs, neighbours, checked_server, type) {
+ function updateWidgets(data) {
+ graphs.graph.data(data);
+ if (!data) {
+ graphs.rrd_pie.destroy();
+ drawRrdTable([]);
+ return;
+ }
+ var rrd_summary = getRrdSummary(data);
+ graphs.rrd_pie = rspamd.drawPie(graphs.rrd_pie,
+ "rrd-pie",
+ rrd_summary,
+ rrd_pie_config);
+ drawRrdTable(rrd_summary);
+ }
+
if (graphs.graph === undefined) {
graphs.graph = initGraph();
}
@@ -164,10 +179,44 @@ function($, D3Evolution, unused) {
}
if (checked_server === "All SERVERS") {
- rspamd.alertMessage('alert-error', 'Data consolidation is not implemented yet');
- graphs.graph.data();
- graphs.rrd_pie.destroy();
- drawRrdTable([]);
+ rspamd.queryNeighbours("graph", function (neighbours_data) {
+ neighbours_data
+ .filter(function (d) { return d.status }) // filter out unavailable neighbours
+ .map(function (d){ return d.data; })
+ .reduce(function (res, curr) {
+ if ((curr[0][0].x !== res[0][0].x) ||
+ (curr[0][curr[0].length - 1].x !== res[0][res[0].length - 1].x)) {
+ rspamd.alertMessage('alert-error',
+ 'Neighbours time extents do not match. Check if time is synchronized on all servers.');
+ updateWidgets();
+ return;
+ }
+
+ let data = [];
+ curr.forEach(function (action, j) {
+ data.push(
+ action.map(function (d, i) {
+ return {
+ x: d.x,
+ y: ((res[j][i].y === null) ? d.y : res[j][i].y + d.y)
+ };
+ })
+ );
+ });
+ updateWidgets(data);
+ });
+ },
+ function (serv, jqXHR, textStatus, errorThrown) {
+ var alert_status = serv.name + '_alerted';
+
+ if (!(alert_status in sessionStorage)) {
+ sessionStorage.setItem(alert_status, true);
+ rspamd.alertMessage('alert-error', 'Cannot receive RRD data from: ' +
+ serv.name + ', error: ' + errorThrown);
+ }
+ }, "GET", {}, {}, {
+ type: type
+ });
return;
}
@@ -183,13 +232,7 @@ function($, D3Evolution, unused) {
xhr.setRequestHeader('Password', rspamd.getPassword());
},
success: function (data) {
- var rrd_summary = getRrdSummary(data);
- graphs.graph.data(data);
- graphs.rrd_pie = rspamd.drawPie(graphs.rrd_pie,
- "rrd-pie",
- rrd_summary,
- rrd_pie_config);
- drawRrdTable(rrd_summary);
+ updateWidgets(data);
},
error: function (jqXHR, textStatus, errorThrown) {
rspamd.alertMessage('alert-error', 'Cannot receive throughput data: ' +
@@ -198,6 +241,5 @@ function($, D3Evolution, unused) {
});
};
-
return interface;
});
diff --git a/interface/js/app/rspamd.js b/interface/js/app/rspamd.js
index 576eda13b..13ffaba49 100644
--- a/interface/js/app/rspamd.js
+++ b/interface/js/app/rspamd.js
@@ -341,7 +341,7 @@ define(['jquery', 'd3pie', 'visibility', 'app/stats', 'app/graph', 'app/config',
$.ajax(req_params);
}
- interface.queryNeighbours = function(req_url, on_success, on_error, method, headers, params) {
+ interface.queryNeighbours = function(req_url, on_success, on_error, method, headers, params, req_data) {
$.ajax({
dataType: "json",
type: "GET",
@@ -378,6 +378,7 @@ define(['jquery', 'd3pie', 'visibility', 'app/stats', 'app/graph', 'app/config',
var req_params = {
type: method,
jsonp: false,
+ data: req_data,
beforeSend: function (xhr) {
xhr.setRequestHeader("Password", getPassword());