Last active
August 29, 2015 14:07
-
-
Save ross-nordstrom/65e7d61bc8e34fc0081d to your computer and use it in GitHub Desktop.
Get process usage
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
#!/usr/bin/env ruby | |
require 'json' | |
p_main = `ps` | |
p_all = `ps -a` | |
users = `who` | |
data = { | |
:local => `ps`.split("\n").size - 1, | |
:tty => `ps a`.split("\n").size - 1, | |
:non_tty => `ps x`.split("\n").size - 1, | |
:total => `ps -A`.split("\n").size - 1 | |
} | |
data[:other] = data[:total] - (data[:local] + data[:tty] + data[:non_tty]) | |
puts data.to_json.gsub(/"/, "'") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment