Skip to content

Instantly share code, notes, and snippets.

@timc3
Created February 25, 2013 12:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timc3/5029570 to your computer and use it in GitHub Desktop.
Save timc3/5029570 to your computer and use it in GitHub Desktop.
Hubot CPU usage script written in Javascript instead of coffeescript nonsense
// Description:
// Report the top 5 local CPU processes
//
// Dependencies:
//
// Configuration:
// None
//
// Commands:
// hubot cpu usage ? - show the top 5 processes
//
// Author:
// Tim Child @ Cantemo
var sys = require('util');
var exec = require('child_process').exec;
var child;
module.exports = function(robot) {
robot.respond(/cpu usage/i, function(msg){
child = exec("top -b -n 1 | head -n 12 | tail -n 5", function (error, stdout, stderr) {
//child = exec("top -b -n 1 | head -n 12 | tail -n 5", (error, stdout, stderr) {
if (error !== null) {
msg.send(error);
} else {
msg.reply(stdout);
}
})
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment