Skip to content

Instantly share code, notes, and snippets.

@mimosz
Created October 28, 2012 13:54
Show Gist options
  • Save mimosz/3968658 to your computer and use it in GitHub Desktop.
Save mimosz/3968658 to your computer and use it in GitHub Desktop.
system info
def self.get()
@diskinfo = `df | grep rootfs | awk '{print $2,$4,$5}'`
@diskinfo = @diskinfo.split(' ')
@diskinfo_size = (@diskinfo[0].to_f / 1024 / 1024).round(2)
@diskinfo_free = (@diskinfo[1].to_f / 1024 / 1024).round(2)
@diskinfo_perc = @diskinfo[2].sub('%','')
@cpu_perc = `vmstat | awk '{print $13}'`.split("\n").last
@mem = `cat /proc/meminfo | grep Mem | awk '{print $2}'`
@mem_total= (Float(@mem.split("\n").first) / 1024).round(2)
@mem_free = (Float(@mem.split("\n").last) / 1024).round(2)
@mem_perc = ((100/@mem_total)*(@mem_total-@mem_free)).round.to_s
@uptime = `uptime`.chomp.to_s.to_s.sub('load average','load')
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment