diff --git a/agents/MeshCentralRouter.exe b/agents/MeshCentralRouter.exe index b0e3c897..a6d264eb 100644 Binary files a/agents/MeshCentralRouter.exe and b/agents/MeshCentralRouter.exe differ diff --git a/agents/meshcore.js b/agents/meshcore.js index 71f29f25..e7732280 100644 --- a/agents/meshcore.js +++ b/agents/meshcore.js @@ -966,6 +966,14 @@ function createMeshCore(agent) { process.coreDumpLocation = null; } break; + case 'getcoredump': + var r = { action: 'getcoredump', value: (process.coreDumpLocation != null) }; + if (process.platform == 'win32') { + r.exists = r.value ? fs.existsSync(process.coreDumpLocation) : false; + } else { + r.exists = (r.value && (process.cwd() != '//')) ? fs.existsSync(process.cwd() + 'core') : false; + } + mesh.SendCommand(JSON.stringify(r)); default: // Unknown action, ignore it. break; @@ -2284,6 +2292,13 @@ function createMeshCore(agent) { break; case 'status': response = 'coredump is: ' + ((process.coreDumpLocation == null) ? 'off' : 'on'); + if (process.coreDumpLocation != null) { + if (process.platform == 'win32') { + if (fs.existsSync(process.coreDumpLocation)) { response += '\r\n CoreDump present at: ' + process.coreDumpLocation; } + } else { + if ((process.cwd() != '//') && fs.existsSync(process.cwd() + 'core')) { response += '\r\n CoreDump present at: ' + process.cwd() + 'core'; } + } + } break; default: response = "Proper usage: coredump on|off|status"; // Display usage diff --git a/meshagent.js b/meshagent.js index b55d9a1c..72d1eee4 100644 --- a/meshagent.js +++ b/meshagent.js @@ -978,6 +978,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) { // Set agent core dump if ((parent.parent.config.settings != null) && ((parent.parent.config.settings.agentcoredump === true) || (parent.parent.config.settings.agentcoredump === false))) { obj.send(JSON.stringify({ action: 'coredump', value: parent.parent.config.settings.agentcoredump })); + if (parent.parent.config.settings.agentcoredump === true) { obj.send(JSON.stringify({ action: 'getcoredump' })); } } // Do this if IP location is enabled on this domain TODO: Set IP location per device group? @@ -1368,6 +1369,15 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) { obj.updateSessions(); break; } + case 'getcoredump': { + // Indicates if the agent has a coredump available + if (command.exists === true) { + //console.log('CoreDump for agent ' + obj.remoteaddrport); + obj.coreDumpPresent = true; + // TODO: We need to look at getting the dump uploaded to the server. + } + break; + } case 'plugin': { if ((parent.parent.pluginHandler == null) || (typeof command.plugin != 'string')) break; try {