Class: Custodian::Samplers::RAM

Inherits:
Sampler
  • Object
show all
Defined in:
lib/custodian/samplers/linux/ram.rb,
lib/custodian/samplers/darwin/ram.rb

Class Method Summary collapse

Methods inherited from Sampler

compatible?, describe, description

Methods included from Utilities

directory_exists?, file_exists?, program_exists?

Class Method Details

.sampleObject



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/custodian/samplers/linux/ram.rb', line 7

def self.sample
  free = `free -m`.match /Mem: +([0-9]+) +([0-9]+) +([0-9]+) +([0-9]+) +([0-9]+) +([0-9]+)/

  {
    "Total"   => "#{free[1]} MB",
    "Used"    => "#{free[2]} MB",
    "Free"    => "#{free[3]} MB",
    "Buffers" => "#{free[4]} MB",
    "Cached"  => "#{free[5]} MB"
  }        
end