Added relay session count.

This commit is contained in:
Ylian Saint-Hilaire 2019-02-18 17:14:00 -08:00
parent 5b427985de
commit 3446ddc611
3 changed files with 14 additions and 1 deletions

View File

@ -25,6 +25,7 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie
obj.remoteaddr = obj.ws._socket.remoteAddress;
obj.domain = domain;
if (obj.remoteaddr.startsWith('::ffff:')) { obj.remoteaddr = obj.remoteaddr.substring(7); }
obj.parent.relaySessionCount++;
// Mesh Rights
const MESHRIGHT_EDITMESH = 1;
@ -193,12 +194,14 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie
// If error, close both sides of the relay.
ws.on('error', function (err) {
obj.parent.relaySessionErrorCount++;
console.log('Relay error from ' + obj.remoteaddr + ', ' + err.toString().split('\r')[0] + '.');
closeBothSides();
});
// If the relay web socket is closed, close both sides.
ws.on('close', function (req) {
obj.parent.relaySessionCount--;
closeBothSides();
});

View File

@ -181,7 +181,15 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
var os = require('os');
var stats = { action: 'serverstats', totalmem: os.totalmem(), freemem: os.freemem() };
if (obj.parent.parent.platform != 'win32') { stats.cpuavg = os.loadavg(); } // else { stats.cpuavg = [ 0.2435345, 0.523234234, 0.6435345345 ]; }
var serverStats = { "User Accounts": Object.keys(obj.parent.users).length, "Device Groups": Object.keys(obj.parent.meshes).length, "Agent Sessions": Object.keys(obj.parent.wsagents).length, "Connected Users": Object.keys(obj.parent.wssessions).length, "Users Sessions": Object.keys(obj.parent.wssessions2).length };
var serverStats = {
"User Accounts": Object.keys(obj.parent.users).length,
"Device Groups": Object.keys(obj.parent.meshes).length,
"Agent Sessions": Object.keys(obj.parent.wsagents).length,
"Connected Users": Object.keys(obj.parent.wssessions).length,
"Users Sessions": Object.keys(obj.parent.wssessions2).length,
"Relay Sessions": obj.parent.relaySessionCount,
"Relay Errors": obj.parent.relaySessionErrorCount
};
if (obj.parent.parent.mpsserver != null) { serverStats['Connected Intel® AMT'] = Object.keys(obj.parent.parent.mpsserver.ciraConnections).length; }
stats.values = { "Server State": serverStats }
try { ws.send(JSON.stringify(stats)); } catch (ex) { }

View File

@ -78,6 +78,8 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
obj.agentBlockedIp = args.agentblockedip; // List of blocked IP addresses for agents
obj.tlsSniCredentials = null;
obj.dnsDomains = {};
obj.relaySessionCount = 0;
obj.relaySessionErrorCount = 0;
// Mesh Rights
const MESHRIGHT_EDITMESH = 1;