class Aio::Module::Cmd::Maipu::ShowSystemPower
Public Class Methods
new()
click to toggle source
Calls superclass method
Aio::Module::Cmd::new
# 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
Public Instance Methods
parse()
click to toggle source
# 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)
click to toggle source
# 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