diff --git a/libs/extenders.js b/libs/extenders.js index 8059c79e..538e9c88 100644 --- a/libs/extenders.js +++ b/libs/extenders.js @@ -143,4 +143,14 @@ module.exports = function(s,config){ s.onWebSocketDisconnectionExtensions.push(callback) } // + s.onGetCpuUsageExtensions = [] + s.onGetCpuUsage = function(callback){ + s.onGetCpuUsageExtensions.push(callback) + } + // + s.onGetRamUsageExtensions = [] + s.onGetRamUsage = function(callback){ + s.onGetRamUsageExtensions.push(callback) + } + // } diff --git a/libs/health.js b/libs/health.js index 95193b72..8926eb14 100644 --- a/libs/health.js +++ b/libs/health.js @@ -34,14 +34,20 @@ module.exports = function(s,config,lang,io){ d = d.replace(/(\r\n|\n|\r)/gm, "").replace(/%/g, "") } callback(d) - }); + s.onGetCpuUsageExtensions.forEach(function(extender){ + extender(d) + }) + }) } else if(k.cmd){ exec(k.cmd,{encoding:'utf8',detached: true},function(err,d){ if(s.isWin===true){ d=d.replace(/(\r\n|\n|\r)/gm,"").replace(/%/g,"") } callback(d) - }); + s.onGetCpuUsageExtensions.forEach(function(extender){ + extender(d) + }) + }) } else { callback(0) } @@ -68,7 +74,10 @@ module.exports = function(s,config,lang,io){ d=(parseInt(d.split('=')[1])/(s.totalmem/1000))*100 } callback(d) - }); + s.onGetRamUsageExtensions.forEach(function(extender){ + extender(d) + }) + }) }else{ callback(0) }