Class: Aio::Module::Cmd::H3C::DisplayMemory
- Inherits:
-
Aio::Module::Cmd::H3C
- Object
- Aio::Module::Cmd
- Aio::Module::Cmd::H3C
- Aio::Module::Cmd::H3C::DisplayMemory
- Includes:
- Aio::Module
- Defined in:
- lib/modules/cmd/h3c/display_memory.rb
Instance Attribute Summary
Attributes inherited from Aio::Module::Cmd
#cmd_info, #context, #device_info, #ext_info, #useful, #warning_klass
Instance Method Summary collapse
-
#initialize ⇒ DisplayMemory
constructor
A new instance of DisplayMemory.
- #parse ⇒ Object
- #parse_default(cont) ⇒ Object
-
#parse_template_3(cont) ⇒ Object
MSR56-60 模板.
Methods inherited from Aio::Module::Cmd
#author, #benchmark, #clear_useful, #cmd_full, #cmd_short, #description, #division, #key_stand, #license, #platform, #ranking, #set_defaults, #type
Methods included from Ui::Verbose
#clear_line, #print_error, #print_good, #progress_bar
Constructor Details
#initialize ⇒ DisplayMemory
Returns a new instance of DisplayMemory.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/modules/cmd/h3c/display_memory.rb', line 8 def initialize super({ :cmd_full => "display memory", :cmd_short => "dis mem", :author => "Elin", :description => "This is H3C Command# display memory", :ranking => Ranking_1, :platform => "all", :benchmark => {} }) end |
Instance Method Details
#parse ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/modules/cmd/h3c/display_memory.rb', line 20 def parse cont = self.context.dup #memory = {} #useful[:memory] = memory case device_template when Template_3 parse_template_3(cont) else parse_default(cont) end end |
#parse_default(cont) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/modules/cmd/h3c/display_memory.rb', line 33 def parse_default(cont) useful[:memory] = {} cont.readline_match_block(/System Total Memory\(bytes\): (?<total_memory>\d+)/) do |block| #block.update(memory, :total_memory) end cont.readline_match_block(/Total Used Memory\(bytes\): (?<used_memory>\d+)/) do |block| #block.update(memory, :used_memory) end cont.readline_match_block(/Used Rate: (?<used_rate>\d+)%/) do |block| block.update(useful[:memory], :used_rate) end end |
#parse_template_3(cont) ⇒ Object
MSR56-60 模板
47 48 49 50 51 52 53 54 |
# File 'lib/modules/cmd/h3c/display_memory.rb', line 47 def parse_template_3(cont) useful[:memory] = {} cont.readline_match_block(/Total Used Free Shared Buffers Cached FreeRatio/) {|b|b} cont.readline_match_block(/Mem: .* (?<used_free>\d+\.\d)%$/) do |block| used = 100 - block[:used_free].to_f block.update(useful[:memory], :used_rate, used.to_s[0,4]) end end |