Class: MemInfo
- Inherits:
-
Object
- Object
- MemInfo
- Defined in:
- lib/mem_info.rb
Defined Under Namespace
Classes: NoProcData
Constant Summary collapse
- @@attributes =
{ :memtotal => "MemTotal", :memfree => "MemFree", :buffers => "Buffers", :cached => "Cached", :swapcached => "SwapCached", :active => "Active", :inactive => "Inactive", :active_anon => "Active\(anon\)", :inactive_anon => "Inactive\(anon\)", :active_file => "Active\(file\)", :inactive_file => "Inactive\(file\)", :unevictable => "Unevictable", :mlocked => "Mlocked", :swaptotal => "SwapTotal", :swapfree => "SwapFree", :dirty => "Dirty", :writeback => "Writeback", :anonpages => "AnonPages", :mapped => "Mapped", :slab => "Slab", :sreclaimable => "SReclaimable", :sunreclaim => "SUnreclaim", :pagetables => "PageTables", :nfs_unstable => "NFS_Unstable", :bounce => "Bounce", :writebacktmp => "WritebackTmp", :commitlimit => "CommitLimit", :committed_as => "Committed_AS", :vmalloctotal => "VmallocTotal", :vmallocused => "VmallocUsed", :vmallocchunk => "VmallocChunk", :directmap4k => "DirectMap4k", :directmap2m => "DirectMap2M" }
Instance Attribute Summary collapse
-
#active ⇒ Object
Returns the value of attribute active.
-
#active_anon ⇒ Object
Returns the value of attribute active_anon.
-
#active_file ⇒ Object
Returns the value of attribute active_file.
-
#anonpages ⇒ Object
Returns the value of attribute anonpages.
-
#bounce ⇒ Object
Returns the value of attribute bounce.
-
#buffers ⇒ Object
Returns the value of attribute buffers.
-
#cached ⇒ Object
Returns the value of attribute cached.
-
#commitlimit ⇒ Object
Returns the value of attribute commitlimit.
-
#committed_as ⇒ Object
Returns the value of attribute committed_as.
-
#directmap2m ⇒ Object
Returns the value of attribute directmap2m.
-
#directmap4k ⇒ Object
Returns the value of attribute directmap4k.
-
#dirty ⇒ Object
Returns the value of attribute dirty.
-
#inactive ⇒ Object
Returns the value of attribute inactive.
-
#inactive_anon ⇒ Object
Returns the value of attribute inactive_anon.
-
#inactive_file ⇒ Object
Returns the value of attribute inactive_file.
-
#mapped ⇒ Object
Returns the value of attribute mapped.
-
#memfree ⇒ Object
Returns the value of attribute memfree.
-
#memtotal ⇒ Object
Returns the value of attribute memtotal.
-
#mlocked ⇒ Object
Returns the value of attribute mlocked.
-
#nfs_unstable ⇒ Object
Returns the value of attribute nfs_unstable.
-
#pagetables ⇒ Object
Returns the value of attribute pagetables.
-
#slab ⇒ Object
Returns the value of attribute slab.
-
#sreclaimable ⇒ Object
Returns the value of attribute sreclaimable.
-
#sunreclaim ⇒ Object
Returns the value of attribute sunreclaim.
-
#swapcached ⇒ Object
Returns the value of attribute swapcached.
-
#swapfree ⇒ Object
Returns the value of attribute swapfree.
-
#swaptotal ⇒ Object
Returns the value of attribute swaptotal.
-
#unevictable ⇒ Object
Returns the value of attribute unevictable.
-
#vmallochunk ⇒ Object
Returns the value of attribute vmallochunk.
-
#vmalloctotal ⇒ Object
Returns the value of attribute vmalloctotal.
-
#vmallocused ⇒ Object
Returns the value of attribute vmallocused.
-
#writeback ⇒ Object
Returns the value of attribute writeback.
-
#writebacktmp ⇒ Object
Returns the value of attribute writebacktmp.
Instance Method Summary collapse
- #free_buffers ⇒ Object
-
#initialize ⇒ MemInfo
constructor
A new instance of MemInfo.
- #memused ⇒ Object
Constructor Details
#initialize ⇒ MemInfo
Returns a new instance of MemInfo.
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/mem_info.rb', line 48 def initialize if File.exists?("/proc/meminfo") File.open("/proc/meminfo", "r") do |file| data = file.read @@attributes.keys.each do |attribute| instance_variable_set("@#{attribute.to_s}", regex_match(attribute, data).to_i) end end else raise NoProcData, "This system doesn't have /proc/meminfo data." end end |
Instance Attribute Details
#active ⇒ Object
Returns the value of attribute active.
4 5 6 |
# File 'lib/mem_info.rb', line 4 def active @active end |
#active_anon ⇒ Object
Returns the value of attribute active_anon.
4 5 6 |
# File 'lib/mem_info.rb', line 4 def active_anon @active_anon end |
#active_file ⇒ Object
Returns the value of attribute active_file.
4 5 6 |
# File 'lib/mem_info.rb', line 4 def active_file @active_file end |
#anonpages ⇒ Object
Returns the value of attribute anonpages.
4 5 6 |
# File 'lib/mem_info.rb', line 4 def anonpages @anonpages end |
#bounce ⇒ Object
Returns the value of attribute bounce.
4 5 6 |
# File 'lib/mem_info.rb', line 4 def bounce @bounce end |
#buffers ⇒ Object
Returns the value of attribute buffers.
4 5 6 |
# File 'lib/mem_info.rb', line 4 def buffers @buffers end |
#cached ⇒ Object
Returns the value of attribute cached.
4 5 6 |
# File 'lib/mem_info.rb', line 4 def cached @cached end |
#commitlimit ⇒ Object
Returns the value of attribute commitlimit.
4 5 6 |
# File 'lib/mem_info.rb', line 4 def commitlimit @commitlimit end |
#committed_as ⇒ Object
Returns the value of attribute committed_as.
4 5 6 |
# File 'lib/mem_info.rb', line 4 def committed_as @committed_as end |
#directmap2m ⇒ Object
Returns the value of attribute directmap2m.
4 5 6 |
# File 'lib/mem_info.rb', line 4 def directmap2m @directmap2m end |
#directmap4k ⇒ Object
Returns the value of attribute directmap4k.
4 5 6 |
# File 'lib/mem_info.rb', line 4 def directmap4k @directmap4k end |
#dirty ⇒ Object
Returns the value of attribute dirty.
4 5 6 |
# File 'lib/mem_info.rb', line 4 def dirty @dirty end |
#inactive ⇒ Object
Returns the value of attribute inactive.
4 5 6 |
# File 'lib/mem_info.rb', line 4 def inactive @inactive end |
#inactive_anon ⇒ Object
Returns the value of attribute inactive_anon.
4 5 6 |
# File 'lib/mem_info.rb', line 4 def inactive_anon @inactive_anon end |
#inactive_file ⇒ Object
Returns the value of attribute inactive_file.
4 5 6 |
# File 'lib/mem_info.rb', line 4 def inactive_file @inactive_file end |
#mapped ⇒ Object
Returns the value of attribute mapped.
4 5 6 |
# File 'lib/mem_info.rb', line 4 def mapped @mapped end |
#memfree ⇒ Object
Returns the value of attribute memfree.
4 5 6 |
# File 'lib/mem_info.rb', line 4 def memfree @memfree end |
#memtotal ⇒ Object
Returns the value of attribute memtotal.
4 5 6 |
# File 'lib/mem_info.rb', line 4 def memtotal @memtotal end |
#mlocked ⇒ Object
Returns the value of attribute mlocked.
4 5 6 |
# File 'lib/mem_info.rb', line 4 def mlocked @mlocked end |
#nfs_unstable ⇒ Object
Returns the value of attribute nfs_unstable.
4 5 6 |
# File 'lib/mem_info.rb', line 4 def nfs_unstable @nfs_unstable end |
#pagetables ⇒ Object
Returns the value of attribute pagetables.
4 5 6 |
# File 'lib/mem_info.rb', line 4 def pagetables @pagetables end |
#slab ⇒ Object
Returns the value of attribute slab.
4 5 6 |
# File 'lib/mem_info.rb', line 4 def slab @slab end |
#sreclaimable ⇒ Object
Returns the value of attribute sreclaimable.
4 5 6 |
# File 'lib/mem_info.rb', line 4 def sreclaimable @sreclaimable end |
#sunreclaim ⇒ Object
Returns the value of attribute sunreclaim.
4 5 6 |
# File 'lib/mem_info.rb', line 4 def sunreclaim @sunreclaim end |
#swapcached ⇒ Object
Returns the value of attribute swapcached.
4 5 6 |
# File 'lib/mem_info.rb', line 4 def swapcached @swapcached end |
#swapfree ⇒ Object
Returns the value of attribute swapfree.
4 5 6 |
# File 'lib/mem_info.rb', line 4 def swapfree @swapfree end |
#swaptotal ⇒ Object
Returns the value of attribute swaptotal.
4 5 6 |
# File 'lib/mem_info.rb', line 4 def swaptotal @swaptotal end |
#unevictable ⇒ Object
Returns the value of attribute unevictable.
4 5 6 |
# File 'lib/mem_info.rb', line 4 def unevictable @unevictable end |
#vmallochunk ⇒ Object
Returns the value of attribute vmallochunk.
4 5 6 |
# File 'lib/mem_info.rb', line 4 def vmallochunk @vmallochunk end |
#vmalloctotal ⇒ Object
Returns the value of attribute vmalloctotal.
4 5 6 |
# File 'lib/mem_info.rb', line 4 def vmalloctotal @vmalloctotal end |
#vmallocused ⇒ Object
Returns the value of attribute vmallocused.
4 5 6 |
# File 'lib/mem_info.rb', line 4 def vmallocused @vmallocused end |
#writeback ⇒ Object
Returns the value of attribute writeback.
4 5 6 |
# File 'lib/mem_info.rb', line 4 def writeback @writeback end |
#writebacktmp ⇒ Object
Returns the value of attribute writebacktmp.
4 5 6 |
# File 'lib/mem_info.rb', line 4 def writebacktmp @writebacktmp end |
Instance Method Details
#free_buffers ⇒ Object
65 66 67 |
# File 'lib/mem_info.rb', line 65 def free_buffers @memfree + @buffers + @cached end |
#memused ⇒ Object
61 62 63 |
# File 'lib/mem_info.rb', line 61 def memused @memtotal - @memfree end |