Is there anyway to get the current CPU/memory usage of another process running on the same machine (in windows) via nodejs. I realise this would be trivial on unix by using ps but I need this functionality on windows (its actually to monitor IE8).
Has anyone else faced this issue?
I think you are looking for Tasklist
. This will give you the pid and memory usage.
Try this:
var spawn = require('child_process').spawn;
ps = spawn('Tasklist');
ps.stdout.on('data', function (data) {
console.log(data);
});
ps.stderr.on('data', function (data) {
console.log('ps stderr: ' + data);
});
I'm not sure if tasklist can do cpu usage. However, you can download and install ProcDump
, then do something similar to the code above.
var spawn = require('child_process').spawn;
ps = spawn('procdump -ma ' + somePid); // or 'procdump iexplorer'
ps.stdout.on('data', function (data) {
console.log(data);
});
ps.stderr.on('data', function (data) {
console.log('ps stderr: ' + data);
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.