add cpu and ram event extensions

merge-requests/60/head
Moe 2019-04-13 17:36:00 -07:00
parent 447315cfef
commit c7700b8eea
2 changed files with 22 additions and 3 deletions

View File

@ -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)
}
//
}

View File

@ -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)
}