From b349b83ef1cbbac55f3477efb613836f3fdcb162 Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Wed, 5 May 2021 17:08:50 -0700 Subject: [PATCH] Initial work on traffic graph. --- meshcentral.js | 8 +++++++- views/default.handlebars | 43 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/meshcentral.js b/meshcentral.js index 689ae3f7..1198c106 100644 --- a/meshcentral.js +++ b/meshcentral.js @@ -1665,6 +1665,7 @@ function CreateMeshCentralServer(config, args) { } // Start collecting server stats every 5 minutes + obj.trafficStats = obj.webserver.getTrafficStats(); setInterval(function () { obj.serverStatsCounter++; var hours = 720; // Start with all events lasting 30 days. @@ -1676,6 +1677,10 @@ function CreateMeshCentralServer(config, args) { var expire = new Date(); expire.setTime(expire.getTime() + (60 * 60 * 1000 * hours)); + // Get traffic data + var trafficStats = obj.webserver.getTrafficDelta(obj.trafficStats); + obj.trafficStats = trafficStats.current; + var data = { time: new Date(), expire: expire, @@ -1686,7 +1691,8 @@ function CreateMeshCentralServer(config, args) { cu: Object.keys(obj.webserver.wssessions).length, us: Object.keys(obj.webserver.wssessions2).length, rs: obj.webserver.relaySessionCount - } + }, + traffic: trafficStats.delta }; if (obj.mpsserver != null) { data.conn.am = 0; diff --git a/views/default.handlebars b/views/default.handlebars index 5dcbb62f..0bca783b 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -1023,6 +1023,8 @@