Created
March 11, 2012 16:17
-
-
Save softwhisper/2016990 to your computer and use it in GitHub Desktop.
Capistrano receipt for general system status
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
namespace :status do | |
desc "Displays memory usage" | |
task :memory do | |
mem = capture("free -m | grep Mem").squeeze(" ").split(" ")[1..-1] | |
total, used, free, shared, buffers, cached = mem | |
puts "\nMemory in (MBs)" | |
puts "----------------------------" | |
puts "Total: #{total}" | |
puts "Used: #{used}" | |
puts "Free: #{free}" | |
puts "Shared: #{shared}" | |
puts "Buffers: #{buffers}" | |
puts "Cached: #{cached}" | |
puts "----------------------------\n\n" | |
end | |
end | |
# Output Example: | |
# ---------------------------- | |
# Memory in (MBs) | |
# Total: 995 | |
# Used: 648 | |
# Free: 346 | |
# Shared: 0 | |
# Buffers: 93 | |
# Cached: 207 | |
---------------------------- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
added squeeze(" ") to only clean spaces