Created
February 25, 2013 12:42
-
-
Save timc3/5029570 to your computer and use it in GitHub Desktop.
Hubot CPU usage script written in Javascript instead of coffeescript nonsense
This file contains hidden or 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
// 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