Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const cmd = require('node-cmd');
- const argv = require('yargs')
- .option('pid', { alias: 'p' })
- .option('interval', { alias: 'i', default: 3000 })
- .demandOption(['pid'])
- .argv;
- setInterval(() => {
- cmd.get("top -p " + argv.port + " -b -d 1 | head -n 8 | tail -1 | awk '{print $9\" \"$10}'", (data) => {
- const result = data.split(" ");
- const cpu = result[0];
- const memory = result[1];
- console.log("CPU:", cpu, "Memory:", memory);
- });
- }, argv.interval);
Advertisement
Add Comment
Please, Sign In to add comment