rm useless module

This commit is contained in:
Tjatse 2014-12-17 11:24:55 +08:00
parent 2bac20f2e4
commit d464150d22
2 changed files with 7 additions and 47 deletions

View File

@ -1,8 +1,5 @@
var usage = require('usage'),
os = require('os'),
exec = require('child_process').exec,
winCPU = require('windows-cpu'),
isWindows = process.platform == 'win32';
var os = require('os'),
exec = require('child_process').exec;
/**
* System states
@ -57,19 +54,11 @@ var stat = module.exports = {
* @param fn
*/
stat.cpuUsage = function(fn){
if (isWindows) {
winCPU.totalLoad(function(err, results){
fn(err, results.reduce(function(p1, p2){
return (p1 + (p2 || p1)) / 2;
}).toFixed(2));
})
} else {
setTimeout(function(ctx, stat1){
var stat2 = ctx.cpuInfo(),
perc = 100 * (1 - (stat2.idle - stat1.idle) / (stat2.total - stat1.total));
fn(null, perc.toFixed(2));
}, 1000, this, this.cpuInfo());
}
setTimeout(function(ctx, stat1){
var stat2 = ctx.cpuInfo(),
perc = 100 * (1 - (stat2.idle - stat1.idle) / (stat2.total - stat1.total));
fn(null, perc.toFixed(2));
}, 1000, this, this.cpuInfo());
};
/**
@ -89,32 +78,4 @@ stat.cpuInfo = function(fn){
'idle' : idle,
'total': total
};
};
/**
* Get memory usage by process id.
* @param {String} pid
* @param {Function} cb
*/
stat.memoryUsage = function(pid, cb){
if (isWindows) {
exec('TaskList /fi "PID eq ' + pid + '" /fo CSV', function(err, stdout, stderr){
if (err) {
return cb(err);
}
var lines = stdout.split('\n');
if (lines != 2) {
return cb(null, '0');
}
var data = lines[1].split(',');
cb(data.length == 0 ? '0' : data[data.length - 1].replace(/[\'\",\s]/g, ''));
})
} else {
usage.lookup(pid, function(err, result){
if (err) {
return cb(err);
}
return cb(null, result.memory);
});
}
};

View File

@ -39,7 +39,6 @@
"chalk": "~0.5.1",
"express": "~4.10.1",
"swig": "~1.4.2",
"usage": "~0.5.0",
"windows-cpu": "~0.1.1",
"socket.io": "~1.2.0",
"nconf": "~0.6.9",