Sha256: 5de3a2bd1c0339119a40f06aa7a8432992bc33ddc8a1a055c319592ddf14809e

Contents?: true

Size: 1.72 KB

Versions: 16

Compression:

Stored size: 1.72 KB

Contents

#coding=utf-8

require "aio/core"

class Aio::Module::Cmd::Maipu::ShowSystemFan < Aio::Module::Cmd::Maipu
	include Aio::Module

	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"],
				:fan_alarm		=> ["<", 1]
				}
		})
	end

	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

	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
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
aio_elin-1.1.4 lib/modules/cmd/maipu/show_system_fan.rb
aio_elin-1.1.3 lib/modules/cmd/maipu/show_system_fan.rb
aio_elin-1.1.2 lib/modules/cmd/maipu/show_system_fan.rb
aio_elin-1.1.1 lib/modules/cmd/maipu/show_system_fan.rb
aio_elin-1.1.0 lib/modules/cmd/maipu/show_system_fan.rb
aio_elin-1.0.9 lib/modules/cmd/maipu/show_system_fan.rb
aio_elin-1.0.8 lib/modules/cmd/maipu/show_system_fan.rb
aio_elin-1.0.7 lib/modules/cmd/maipu/show_system_fan.rb
aio_elin-1.0.6 lib/modules/cmd/maipu/show_system_fan.rb
aio_elin-1.0.5 lib/modules/cmd/maipu/show_system_fan.rb
aio_elin-1.0.4 lib/modules/cmd/maipu/show_system_fan.rb
aio_elin-1.0.3 lib/modules/cmd/maipu/show_system_fan.rb
aio_elin-1.0.2 lib/modules/cmd/maipu/show_system_fan.rb
aio_elin-1.0.1 lib/modules/cmd/maipu/show_system_fan.rb
aio_elin-1.0.0 lib/modules/cmd/maipu/show_system_fan.rb
aio_elin-0.0.1 lib/modules/cmd/maipu/show_system_fan.rb