Class: Aio::Module::Cmd::Cisco::ShowEnv
- Inherits:
-
Aio::Module::Cmd::Cisco
- Object
- Aio::Module::Cmd
- Aio::Module::Cmd::Cisco
- Aio::Module::Cmd::Cisco::ShowEnv
- Includes:
- Aio::Module
- Defined in:
- lib/modules/cmd/cisco/show_env.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 ⇒ ShowEnv
constructor
A new instance of ShowEnv.
- #parse ⇒ Object
- #parse_tmp_1(cont) ⇒ Object
- #parse_tmp_2(cont) ⇒ Object
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 ⇒ ShowEnv
Returns a new instance of ShowEnv.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/modules/cmd/cisco/show_env.rb', line 8 def initialize super({ :cmd_full => "show environment", :cmd_short => "sh env", :author => "Elin", :description => "This is Cisco Command# show environment", :ranking => Ranking_1, :platform => "all", :benchmark => { :power_status => ["==", "Normal"], :fan_status => ["=~", "OK"], :cpu_status => ["==", "Normal"], } }) end |
Instance Method Details
#parse ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/modules/cmd/cisco/show_env.rb', line 24 def parse cont = self.context.dup # 是有版本区别的,要分开对待 case device_template when Template_1, Template_2 parse_tmp_1(cont) when Template_4 parse_tmp_2(cont) end end |
#parse_tmp_1(cont) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/modules/cmd/cisco/show_env.rb', line 36 def parse_tmp_1(cont) useful[:power] = {} cont.readline_match_block(/SYSTEM POWER SUPPLY STATUS/) {|b|b} cont.readline_match_block(/==========================/) {|b|b} cont.readline_range_loop(/Internal Power/, reg_blank) do |cont_layer| power = {} cont_layer.readline_match_block(/Internal Power Supply (?<power_id>\d+) Type: (?<type>.*)/) do |block| power_id = block[:power_id] useful[:power]["slot_#{power_id}"] = power block.update(power, :power_id) block.update(power, :type) end cont_layer.readline_match_block(/Output Status: (?<power_status>.*)/) do |block| block.warning_serious(power, :power_status, self) end end useful[:fan] = {} cont.readline_match_block(/SYSTEM FAN STATUS/) {|b|b} cont.readline_match_block(/=================/) {|b|b} cont.readline_match_block_loop(/Fan (?<fan_id>\d+) (?<fan_status>.*)/, reg_blank) do |block| fan = {} fan_id = block[:fan_id] useful[:fan]["slot_#{fan_id}"] = fan block.update(fan, :fan_id) block.warning_serious(fan, :fan_status, self) end cont.readline_match_block(/SYSTEM TEMPERATURE STATUS/) {|b|b} cont.readline_match_block(/=========================/) {|b|b} cont.readline_match_block(/CPU temperature: (?<cpu_temperature>\d+) Celsius, (?<cpu_status>.*)/) do |block| useful[:temperature] = {} block.update(useful[:temperature], :cpu_temperature) block.warning_serious(useful[:temperature], :cpu_status, self) end end |
#parse_tmp_2(cont) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/modules/cmd/cisco/show_env.rb', line 73 def parse_tmp_2(cont) useful[:fan] = {} cont.readline_match_block(/Main Power Supply is AC/) {|b|b} cont.readline_match_block(reg_blank) {|b|b} cont.readline_match_block_loop(/Fan (?<fan_id>\d+) (?<fan_status>.*)/, reg_blank) do |block| fan = {} fan_id = block[:fan_id] useful[:fan]["slot_#{fan_id}"] = fan block.update(fan, :fan_id) block.warning_serious(fan, :fan_status, self) end end |