Sha256: d5696340a448fef5739b1dfba4f75e2114bbc8f0fbebc443205ba80568c17d22

Contents?: true

Size: 1.73 KB

Versions: 2

Compression:

Stored size: 1.73 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", '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

2 entries across 2 versions & 1 rubygems

Version Path
aio_elin-1.1.8 lib/modules/cmd/maipu/show_system_fan.rb
aio_elin-1.1.7 lib/modules/cmd/maipu/show_system_fan.rb