Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 42 lines (33 sloc) 1.09 KB
#!/usr/bin/env node
var exec = require('child_process').exec;
//$13 should be name?
var cmd = "ps aux | awk '/chroot_runner/ && !/awk/ {print $3,$4,$2,$5,$6,$10,$9}' | sort -r | head -n 50";
require('colors');
var top = function() {
console.log('cpu\tmem\tvsz\trss\tpid\ttime\tdate'.magenta.bold);
exec(cmd, function(err, stdout) {
var data = stdout.split('\n');
//console.log(stdout);
data.forEach(function(l) {
var line = l.split(' ');
if (line[1]) {
for (var i = 2; i < 7; i++) {
line[i] = line[i].white;
}
if (parseFloat(line[0]) > 0.75) {
line[0] = line[0].red.bold;
} else {
line[0] = line[0].white;
}
if (parseFloat(line[1]) > 0.75) {
line[1] = line[1].red.bold;
} else {
line[1] = line[1].white;
}
console.log(line.join('\t'));
}
});
});
};
top();
setInterval(top, 2000);