Class: Aio::Module::Cmd::Maipu::ShowSystemFan
- Inherits:
-
Aio::Module::Cmd::Maipu
- Object
- Aio::Module::Cmd
- Aio::Module::Cmd::Maipu
- Aio::Module::Cmd::Maipu::ShowSystemFan
- Includes:
- Aio::Module
- Defined in:
- lib/modules/cmd/maipu/show_system_fan.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 ⇒ ShowSystemFan
constructor
A new instance of ShowSystemFan.
- #parse ⇒ Object
- #parse_fan(context) ⇒ 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 ⇒ ShowSystemFan
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/modules/cmd/maipu/show_system_fan.rb', line 8 def initialize super({ :cmd_full => "show system fan", :cmd_short => "sh sys fan", :author => "Elin", :description => "This is Maipu Command# show system fan", :ranking => Ranking_1, :platform => "all", :benchmark => { :fan_status => ["==", "NORMAL", 'Normal'], :fan_alarm => ["<", 1] } }) end |
Instance Method Details
#parse ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/modules/cmd/maipu/show_system_fan.rb', line 23 def parse cont = self.context.dup useful[:fan] = {} cont.readline_range_loop(/System FAN Information/, reg_blank) do |cont_layer| parse_fan(cont_layer) end end |
#parse_fan(context) ⇒ Object
32 33 34 35 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 |
# File 'lib/modules/cmd/maipu/show_system_fan.rb', line 32 def parse_fan(context) fan = {} fan_id = nil context.readline_match_block(/System FAN Information\(Fan (?<fan_id>\d+) - (?<state>.*)\)/) do |block| fan_id = block[:fan_id] useful[:fan]["slot_#{fan_id}"] = fan block.update(fan, :fan_id) block.update(fan, :state) end if fan[:state] =~ /ONLINE/ context.readline_match_block(/Status: (?<fan_status>.*)/) do |block| block.warning_serious(fan, :fan_status, self) end context.readline_match_block(/Last-Alarm: (?<fan_alarm>\d+)/) do |block| block.warning_serious(fan, :fan_alarm, self) end context.readline_match_block(/Serial No\.: (?<sn>.*)/) do |block| block.update(fan, :sn) end context.readline_match_block(/Description: (?<description>.*)/) do |block| block.update(fan, :description) end end context.readline_match_block(/STATISTICS: (?<in>\d+) IN, (?<out>\d+) OUT, (?<in_error>\d+) IERR, (?<out_error>\d+) OERR/) do |block| stat = {} fan[:statistics] = stat block.update(stat, :in) block.update(stat, :out) block.update(stat, :in_error) block.update(stat, :out_error) end end |