Fixed device group stat counter

This commit is contained in:
Ylian Saint-Hilaire 2020-05-15 15:39:16 -07:00
parent 0e7114c79b
commit f0ea1c89d3
2 changed files with 6 additions and 2 deletions

View File

@ -328,9 +328,13 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
var os = require('os'); var os = require('os');
var stats = { action: 'serverstats', totalmem: os.totalmem(), freemem: os.freemem() }; var stats = { action: 'serverstats', totalmem: os.totalmem(), freemem: os.freemem() };
if (parent.parent.platform != 'win32') { stats.cpuavg = os.loadavg(); } if (parent.parent.platform != 'win32') { stats.cpuavg = os.loadavg(); }
// Count the number of device groups that are not deleted
var activeDeviceGroups = 0;
for (var i in parent.meshes) { if (parent.meshes[i].deleted == null) { activeDeviceGroups++; } } // This is not ideal for performance, we want to dome something better.
var serverStats = { var serverStats = {
UserAccounts: Object.keys(parent.users).length, UserAccounts: Object.keys(parent.users).length,
DeviceGroups: Object.keys(parent.meshes).length, DeviceGroups: activeDeviceGroups,
AgentSessions: Object.keys(parent.wsagents).length, AgentSessions: Object.keys(parent.wsagents).length,
ConnectedUsers: Object.keys(parent.wssessions).length, ConnectedUsers: Object.keys(parent.wssessions).length,
UsersSessions: Object.keys(parent.wssessions2).length, UsersSessions: Object.keys(parent.wssessions2).length,