Module: Host::Linux::Memory

Includes:
Hashifier
Defined in:
lib/host/linux/memory.rb

Overview

Implements the retrieving of memory information on Linux systems.

Instance Method Summary collapse

Methods included from Hashifier

#hashify

Instance Method Details

#buffers(refresh = false) ⇒ Object

Sugar. Equivalent to Host::Memory.get(‘Buffers’) with implicit transformation to integer (in kB)



31
32
33
34
# File 'lib/host/linux/memory.rb', line 31

def buffers(refresh=false)
  get_meminfo(true) if refresh
  as_integer @info[:Buffers]
end

#free(refresh = false) ⇒ Object

Sugar. Equivalent to Host::Memory.get(‘MemFree’) with implicit transformation to integer (in kB).



24
25
26
27
# File 'lib/host/linux/memory.rb', line 24

def free(refresh=false)
  get_meminfo(true) if refresh
  as_integer @info[:MemFree]
end

#get(key) ⇒ Object

Retrieves specific information for the given key (as some exotic information in /proc/meminfo, for instance).



44
45
46
# File 'lib/host/linux/memory.rb', line 44

def get(key)
  @info[key.to_sym]
end

#refreshObject

Refreshes your memory information, reading /proc/meminfo once again



37
38
39
40
# File 'lib/host/linux/memory.rb', line 37

def refresh
  get_meminfo(true)
  self
end

#total(refresh = false) ⇒ Object

Just sugar. Equivalent to Host::Memory.get(‘MemTotal’) with implicit transformation to integer (in kB) You can pass it a boolean option. If true, information will be reloaded. Defaults to false. Equivalent to:

Host::Memory.refresh.total


17
18
19
20
# File 'lib/host/linux/memory.rb', line 17

def total(refresh=false)
  get_meminfo(true) if refresh
  as_integer @info[:MemTotal]
end