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