Created
October 14, 2013 15:24
-
-
Save ykrkn/6977391 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// run top -p<PID> -b -d 1.0 > tmpfile | |
// code for prepare below | |
var fs = require('fs'); | |
var FILESRC; | |
var PID; | |
var SEPARATOR=","; | |
process.argv.forEach(function(val, index, array) { | |
// console.log(index + ': ' + val); | |
if(index == 2){ FILESRC = val; } | |
if(index == 3){ PID = val; } | |
}); | |
var dst = fs.readFileSync(FILESRC, {encoding:'utf8'}).split("\n").filter(function(it){ | |
if(0 == it.indexOf(PID)) return true; | |
return false; | |
}).map(function(it){ | |
var res = it.split(/\s+/); | |
res[5] = res[5].replace("m", ""); | |
return res.join(SEPARATOR); | |
}); | |
console.log(dst.join("\n")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment