Class: Metrix::Memory
Constant Summary collapse
- MAPPING =
{ "MemTotal" => :mem_total, "MemFree" => :mem_free, "Buffers" => :buffers, "Cached" => :cached, "SwapCached" => :swap_cached, "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" => :swap_total, "SwapFree" => :swap_free, "Dirty" => :dirty, "Writeback" => :writeback, "AnonPages" => :anon_pages, "Mapped" => :mapped, "Shmem" => :shmem, "Slab" => :slab, "SReclaimable" => :s_reclaimable, "SUnreclaim" => :s_unreclaim, "KernelStack" => :kernel_stack, "PageTables" => :page_tables, "NFS_Unstable" => :nfs_unstable, "Bounce" => :bounce, "WritebackTmp" => :writeback_tmp, "CommitLimit" => :commit_limit, "Committed_AS" => :committed_as, "VmallocTotal" => :vmalloc_total, "VmallocUsed" => :vmalloc_used, "VmallocChunk" => :vmalloc_chunk, "HardwareCorrupted" => :hardware_corrupted, "AnonHugePages" => :anon_huge_pages, "HugePages_Total" => :huge_pages_total, "HugePages_Free" => :huge_pages_free, "HugePages_Rsvd" => :huge_pages_rsvd, "HugePages_Surp" => :huge_pages_surp, "Hugepagesize" => :hugepagesize, "DirectMap4k" => :direct_map4k, "DirectMap2M" => :direct_map2m, }
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #extract(data = nil) ⇒ Object
-
#initialize(data) ⇒ Memory
constructor
A new instance of Memory.
- #parsed ⇒ Object
Methods inherited from Base
#cast_int, ignore, #ignore_metric?, ignore_metrics, inherited, known_metrics, #metrics, prefix, #prefix, set_known_metrics, set_prefix, subclasses, #tagged_metrics, #tags, #unfiltered_metrics
Constructor Details
#initialize(data) ⇒ Memory
Returns a new instance of Memory.
7 8 9 10 |
# File 'lib/metrix/memory.rb', line 7 def initialize(data) @data = data @time = Time.now end |
Instance Method Details
#extract(data = nil) ⇒ Object
65 66 67 68 69 70 |
# File 'lib/metrix/memory.rb', line 65 def extract(data = nil) MAPPING.values.inject({}) do |hash, method| hash[method] = send(method) hash end end |
#parsed ⇒ Object
72 73 74 |
# File 'lib/metrix/memory.rb', line 72 def parsed @parsed ||= Hash[@data.scan(/^(.*?):\s*(\d+)/).map { |k, v| [k, cast_int(v)] }] end |