diff --git a/meshcentral.js b/meshcentral.js
index 82bdfd79..e9766eae 100644
--- a/meshcentral.js
+++ b/meshcentral.js
@@ -802,22 +802,20 @@ function CreateMeshCentralServer(config, args) {
// Start collecting server stats every 5 minutes
setInterval(function () {
- obj.db.getStats(function (dbstats) {
- var data = {
- time: new Date(),
- mem: process.memoryUsage(),
- db: dbstats,
- cpu: process.cpuUsage(),
- conn: {
- ca: Object.keys(obj.webserver.wsagents).length,
- cu: Object.keys(obj.webserver.wssessions).length,
- us: Object.keys(obj.webserver.wssessions2).length,
- rs: obj.webserver.relaySessionCount
- }
- };
- if (obj.mpsserver != null) { data.conn.am = Object.keys(obj.mpsserver.ciraConnections).length; }
- obj.db.SetServerStats(data);
- });
+ var data = {
+ time: new Date(),
+ mem: process.memoryUsage(),
+ //cpu: process.cpuUsage(),
+ conn: {
+ ca: Object.keys(obj.webserver.wsagents).length,
+ cu: Object.keys(obj.webserver.wssessions).length,
+ us: Object.keys(obj.webserver.wssessions2).length,
+ rs: obj.webserver.relaySessionCount
+ }
+ };
+ if (obj.mpsserver != null) { data.conn.am = Object.keys(obj.mpsserver.ciraConnections).length; }
+ obj.db.SetServerStats(data); // Save the stats to the database
+ obj.DispatchEvent(['*'], obj, { action: 'servertimelinestats', data: data }); // Event the server stats
}, 300000);
//obj.debug(1, 'Server started');
diff --git a/package.json b/package.json
index 381c5538..e6956eba 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "meshcentral",
- "version": "0.3.1-e",
+ "version": "0.3.1-g",
"keywords": [
"Remote Management",
"Intel AMT",
diff --git a/views/default-min.handlebars b/views/default-min.handlebars
index 5dcc8dfa..7ef941d7 100644
--- a/views/default-min.handlebars
+++ b/views/default-min.handlebars
@@ -1 +1 @@
-
MeshCentral
↔
My Devices My Account My Events My Files My Users My Server
General Desktop Terminal Files Events Intel® AMT Console
Server disconnected , click to reconnect .
My Account Device Groups (
New )
My Files These files are shared publicly, click "link" to get public url.
✓
✗
My Server Server actions
Server Statistics
Intel® AMT Redirection port or KVM feature is disabled, click here to enable it.
Remote computer is not powered on, click here to issue a power command.
Intel® AMT Redirection port or KVM feature is disabled, click here to enable it.
Remote computer is not powered on, click here to issue a power command.
Show
Last 60 Last 120 Last 250 Last 500 Last 1000
General -
Events -
Show
Last 60 Last 120 Last 250 Last 500 Last 1000
Local file upload Server file selection File Selection
Agent Remote Desktop 100% 87.5% 75% 62.5% 50% 37.5% 25% 12.5% Scaling
Fast Medium Slow Very slow Frame rate
Intel® AMT Hardware KVM RLE8, Fastest RLE16, Recommended RAW8, Slow RAW16, Very Slow Image Encoding
\ No newline at end of file
+ MeshCentral
↔
My Devices My Account My Events My Files My Users My Server
General Desktop Terminal Files Events Intel® AMT Console
Server disconnected , click to reconnect .
My Account Device Groups (
New )
My Files These files are shared publicly, click "link" to get public url.
✓
✗
My Server Server actions
Server Statistics
Intel® AMT Redirection port or KVM feature is disabled, click here to enable it.
Remote computer is not powered on, click here to issue a power command.
Intel® AMT Redirection port or KVM feature is disabled, click here to enable it.
Remote computer is not powered on, click here to issue a power command.
Show
Last 60 Last 120 Last 250 Last 500 Last 1000
General -
Events -
Show
Last 60 Last 120 Last 250 Last 500 Last 1000
Local file upload Server file selection File Selection
Agent Remote Desktop 100% 87.5% 75% 62.5% 50% 37.5% 25% 12.5% Scaling
Fast Medium Slow Very slow Frame rate
Intel® AMT Hardware KVM RLE8, Fastest RLE16, Recommended RAW8, Slow RAW16, Very Slow Image Encoding
\ No newline at end of file
diff --git a/views/default.handlebars b/views/default.handlebars
index 0f035572..356679ff 100644
--- a/views/default.handlebars
+++ b/views/default.handlebars
@@ -744,14 +744,13 @@
-
@@ -1591,6 +1590,7 @@
masterUpdate(32);
}
switch (message.event.action) {
+ case 'servertimelinestats': { addServerTimelineStats(message.event.data); break; }
case 'accountcreate':
case 'accountchange': {
// An account was created or changed
@@ -6462,18 +6462,20 @@
var x = '', dateHeader = null;
for (var i in events) {
var event = events[i], time = new Date(event.time);
- if (time.toLocaleDateString() != dateHeader) {
- if (dateHeader != null) x += '';
- x += '' + time.toLocaleDateString() + ' ';
- dateHeader = time.toLocaleDateString();
- }
- var icon = 'si3';
- if (event.etype == 'user') icon = 'm2';
- if (event.etype == 'server') icon = 'si3';
+ if (event.msg) {
+ if (time.toLocaleDateString() != dateHeader) {
+ if (dateHeader != null) x += '
';
+ x += '' + time.toLocaleDateString() + ' ';
+ dateHeader = time.toLocaleDateString();
+ }
+ var icon = 'si3';
+ if (event.etype == 'user') icon = 'm2';
+ if (event.etype == 'server') icon = 'si3';
- var msg = event.msg.split('(R)').join('®');
- if (event.username && event.username != userinfo.name) { msg += ': ' + event.username; }
- x += '
' + time.toLocaleTimeString() + ' - ' + msg + ' ';
+ var msg = event.msg.split('(R)').join('®');
+ if (event.username && event.username != userinfo.name) { msg += ': ' + event.username; }
+ x += '
' + time.toLocaleTimeString() + ' - ' + msg + ' ';
+ }
}
if (dateHeader != null) x += '
';
if (x == '') x = "No Events Found ";
@@ -7259,6 +7261,7 @@
data: { labels: [], datasets: [{ label: '', backgroundColor: 'rgba(255, 99, 132, .5)', borderColor: 'rgb(255, 99, 132)', data: [], fill: true }] },
options: {
responsive: true,
+ maintainAspectRatio: false,
scales: {
xAxes: [{ type: 'time', time: { tooltipFormat: 'll HH:mm' }, display: true, scaleLabel: { display: false, labelString: '' } }],
yAxes: [{ display: true, scaleLabel: { display: true, labelString: '' } }]
@@ -7269,6 +7272,28 @@
function refreshServerTimelineStats(stats) { meshserver.send({ action: 'servertimelinestats', hours: 24 }); }
function pastDate(hours) { var t = new Date(); t.setTime(t.getTime() - (60 * 60 * 1000 * hours)); return t; }
function setServerTimelineStats(stats) { serverTimelineStats = stats; updateServerTimelineStats(); }
+ function addServerTimelineStats(stats) {
+ if (serverTimelineStats == null) return;
+ serverTimelineStats.push(stats);
+ var chartType = Q('p40type').value;
+ if (chartType == 0) {
+ serverTimelineConfig.data.datasets[0].data.push({ x: stats.time, y: stats.conn.ca });
+ serverTimelineConfig.data.datasets[1].data.push({ x: stats.time, y: stats.conn.cu });
+ serverTimelineConfig.data.datasets[2].data.push({ x: stats.time, y: stats.conn.us });
+ serverTimelineConfig.data.datasets[3].data.push({ x: stats.time, y: stats.conn.rs });
+ } else if (chartType == 1) {
+ serverTimelineConfig.data.datasets[0].data.push({ x: stats.time, y: stats.mem.external / (1024 * 1024) });
+ serverTimelineConfig.data.datasets[1].data.push({ x: stats.time, y: stats.mem.heapUsed / (1024 * 1024) });
+ serverTimelineConfig.data.datasets[2].data.push({ x: stats.time, y: stats.mem.heapTotal / (1024 * 1024) });
+ serverTimelineConfig.data.datasets[3].data.push({ x: stats.time, y: stats.mem.rss / (1024 * 1024) });
+ } /* else if (chartType == 2) {
+ serverTimelineConfig.data.datasets[0].data.push({ x: stats.time, y: stats.db.meshes });
+ serverTimelineConfig.data.datasets[1].data.push({ x: stats.time, y: stats.db.nodes });
+ serverTimelineConfig.data.datasets[2].data.push({ x: stats.time, y: stats.db.users });
+ serverTimelineConfig.data.datasets[3].data.push({ x: stats.time, y: stats.db.total });
+ } */
+ updateServerTimelineHours();
+ }
function updateServerTimelineHours() { serverTimelineConfig.options.scales.xAxes[0].time = { min: pastDate(Q('p40time').value) }; window.serverMainStats.update(); }
function setupServerTimelineStats() { window.serverMainStats = new Chart(document.getElementById('serverMainStats').getContext('2d'), serverTimelineConfig); }
@@ -7314,7 +7339,7 @@
data.datasets[2].data.push({ x: serverTimelineStats[i].time, y: serverTimelineStats[i].mem.heapTotal / (1024 * 1024) });
data.datasets[3].data.push({ x: serverTimelineStats[i].time, y: serverTimelineStats[i].mem.rss / (1024 * 1024) });
}
- } else if (chartType == 2) { // Database
+ } /*else if (chartType == 2) { // Database
serverTimelineConfig.options.scales.yAxes[0].scaleLabel.labelString = 'Records';
data = {
labels: [pastDate(0), timeAfter],
@@ -7331,7 +7356,7 @@
data.datasets[2].data.push({ x: serverTimelineStats[i].time, y: serverTimelineStats[i].db.users });
data.datasets[3].data.push({ x: serverTimelineStats[i].time, y: serverTimelineStats[i].db.total });
}
- }
+ }*/
serverTimelineConfig.data = data;
window.serverMainStats.update();
}