class Rubyipmi::Ipmitool::Sensor
Public Class Methods
new(line)
click to toggle source
# File lib/rubyipmi/ipmitool/commands/sensors.rb, line 24 def initialize(line) parse(line) self[:name] = normalize(self[:name]) end
Private Instance Methods
normalize(text)
click to toggle source
# File lib/rubyipmi/ipmitool/commands/sensors.rb, line 31 def normalize(text) text.gsub(/\ /, '_').gsub(/\./, '').downcase end
parse(line)
click to toggle source
Parse the individual sensor Note: not all fields will exist on every server
# File lib/rubyipmi/ipmitool/commands/sensors.rb, line 37 def parse(line) fields = [:name, :value, :unit, :status, :type, :state, :lower_nonrec, :lower_crit, :lower_noncrit, :upper_crit, :upper_nonrec, :asserts_enabled, :deasserts_enabled] # skip the header data = line.split(/\|/) # should we ever encounter a field not in the fields list, just use a counter based fieldname i = 0 data.each do |value| field ||= fields.shift || "field#{i}" self[field] = value.strip i = i.next end end