From d4236385cc1d1078a17b20ced05b2110960bcbb9 Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Sat, 21 Mar 2020 17:33:09 -0700 Subject: [PATCH] Added server stats graph breaks. --- meshcentral.js | 2 ++ views/default.handlebars | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/meshcentral.js b/meshcentral.js index 44cca64d..0c7a262b 100644 --- a/meshcentral.js +++ b/meshcentral.js @@ -70,6 +70,7 @@ function CreateMeshCentralServer(config, args) { obj.serverWarnings = []; // List of warnings that should be shown to administrators obj.cookieUseOnceTable = {}; // List of cookies that are already expired obj.cookieUseOnceTableCleanCounter = 0; // Clean the cookieUseOnceTable each 20 additions + obj.firstStats = true; // True until this server saves it's not stats to the database // Server version obj.currentVer = null; @@ -1272,6 +1273,7 @@ function CreateMeshCentralServer(config, args) { } }; if (obj.mpsserver != null) { data.conn.am = Object.keys(obj.mpsserver.ciraConnections).length; } + if (obj.firstStats === true) { delete obj.firstStats; data.first = true; } obj.db.SetServerStats(data); // Save the stats to the database obj.DispatchEvent(['*'], obj, { action: 'servertimelinestats', data: data }); // Event the server stats }, 300000); diff --git a/views/default.handlebars b/views/default.handlebars index 2b0c4b91..0795560a 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -10709,6 +10709,12 @@ }; for (var i = 0; i < serverTimelineStats.length; i++) { var t = new Date(serverTimelineStats[i].time); + if (serverTimelineStats[i].first == true) { + data.datasets[0].data.push({ x: serverTimelineStats[i].time - 1, y: NaN }); + data.datasets[1].data.push({ x: serverTimelineStats[i].time - 1, y: NaN }); + data.datasets[2].data.push({ x: serverTimelineStats[i].time - 1, y: NaN }); + data.datasets[3].data.push({ x: serverTimelineStats[i].time - 1, y: NaN }); + } if (serverTimelineStats[i].conn) { data.datasets[0].data.push({ x: serverTimelineStats[i].time, y: serverTimelineStats[i].conn.ca }); data.datasets[1].data.push({ x: serverTimelineStats[i].time, y: serverTimelineStats[i].conn.cu }); @@ -10729,6 +10735,12 @@ ] }; for (var i = 0; i < serverTimelineStats.length; i++) { + if (serverTimelineStats[i].first == true) { + data.datasets[0].data.push({ x: serverTimelineStats[i].time - 1, y: NaN }); + data.datasets[1].data.push({ x: serverTimelineStats[i].time - 1, y: NaN }); + data.datasets[2].data.push({ x: serverTimelineStats[i].time - 1, y: NaN }); + data.datasets[3].data.push({ x: serverTimelineStats[i].time - 1, y: NaN }); + } data.datasets[0].data.push({ x: serverTimelineStats[i].time, y: serverTimelineStats[i].mem.external / (1024 * 1024) }); data.datasets[1].data.push({ x: serverTimelineStats[i].time, y: serverTimelineStats[i].mem.heapUsed / (1024 * 1024) }); data.datasets[2].data.push({ x: serverTimelineStats[i].time, y: serverTimelineStats[i].mem.heapTotal / (1024 * 1024) });