Class: Aio::Module::Cmd::Cisco::ShowProcessMemory
- Inherits:
-
Aio::Module::Cmd::Cisco
- Object
- Aio::Module::Cmd
- Aio::Module::Cmd::Cisco
- Aio::Module::Cmd::Cisco::ShowProcessMemory
- Includes:
- Aio::Module
- Defined in:
- lib/modules/cmd/cisco/show_process_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 ⇒ ShowProcessMemory
constructor
A new instance of ShowProcessMemory.
- #parse ⇒ Object
- #parse_def(cont) ⇒ Object
- #parse_tmp_2(cont) ⇒ Object
-
#ratio(fir, sec) ⇒ Object
返回为String.
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 ⇒ ShowProcessMemory
Returns a new instance of ShowProcessMemory.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/modules/cmd/cisco/show_process_memory.rb', line 8 def initialize super({ :cmd_full => "show process memory", :cmd_short => "sh pro m", :author => "Elin", :description => "This is Cisco Command# show process memory", :ranking => Ranking_1, :platform => "all", :benchmark => { :proc_ratio => ["<", 70.0], :io_ratio => ["<", 70.0] } }) end |
Instance Method Details
#parse ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/modules/cmd/cisco/show_process_memory.rb', line 23 def parse cont = self.context.dup useful[:memory] = {} case device_template when Template_1 parse_def(cont) when Template_2 if device_version =~ /12.2\(33\)/ # 当是Cisco7606 的时候,即使是12.2(17r)S4,Memory的模板也是默认模板 parse_def(cont) else parse_tmp_2(cont) end end end |
#parse_def(cont) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/modules/cmd/cisco/show_process_memory.rb', line 46 def parse_def(cont) cont.readline_match_block(/Processor Pool Total: (?<proc_total>\d+) Used: (?<proc_used>\d+)/) do |block| proc_ratio = ratio(block[:proc_used], block[:proc_total]) block.warning_serious(useful[:memory], :proc_ratio, self, {:string => proc_ratio}) end cont.readline_match_block(/I\/O Pool Total: (?<io_total>\d+) Used: (?<io_used>\d+)/) do |block| io_ratio = ratio(block[:io_used], block[:io_total]) #block.warning_serious(useful[:memory], :io_ratio, self, io_ratio) block.update(useful[:memory], :io_ratio, io_ratio) end end |
#parse_tmp_2(cont) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/modules/cmd/cisco/show_process_memory.rb', line 39 def parse_tmp_2(cont) cont.readline_match_block(/System Memory : (?<proc_total>\d+)K total, (?<proc_used>\d+)K used/) do |block| proc_ratio = ratio(block[:proc_used], block[:proc_total]) block.warning_serious(useful[:memory], :proc_ratio, self, {:string => proc_ratio}) end end |
#ratio(fir, sec) ⇒ Object
返回为String
59 60 61 |
# File 'lib/modules/cmd/cisco/show_process_memory.rb', line 59 def ratio(fir, sec) format("%.2f", ((fir.to_f / sec.to_f) * 100)) end |