Created
December 20, 2013 23:32
-
-
Save xraystyle/8063335 to your computer and use it in GitHub Desktop.
Quick script to get the total memory usage for a specific user on a server.
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 -w | |
unless ARGV[0] | |
puts "\nSpecify a username. \n\nUsage:" | |
puts "usermem UserName\n\n" | |
exit! | |
end | |
total = 0 | |
mem = `ps -u #{ARGV[0]} -o rss` | |
mem = mem.split("\n") | |
mem.delete_at(0) | |
mem.each do |val| | |
total = total + val.to_i | |
end | |
puts "Total memory usage for #{ARGV[0]} in MB: #{total / 1024}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment