class Rubyipmi::Ipmitool::Sensors

Public Class Methods

new(opts = ObservableHash.new) click to toggle source
Calls superclass method Rubyipmi::BaseCommand.new
# File lib/rubyipmi/ipmitool/commands/sensors.rb, line 5
def initialize(opts = ObservableHash.new)
  super("ipmitool", opts)
end

Public Instance Methods

count() click to toggle source
# File lib/rubyipmi/ipmitool/commands/sensors.rb, line 18
def count
  list.count
end
fanlist(refreshdata=false) click to toggle source

returns a hash of fan sensors where the key is fan name and value is the sensor

# File lib/rubyipmi/ipmitool/commands/sensors.rb, line 27
def fanlist(refreshdata=false)
  refresh if refreshdata
  flist = {}
  list.each do | name,sensor |
    if name =~ /.*fan.*/
        flist[name] = sensor
    end
  end
  return flist
end
getsensors() click to toggle source
# File lib/rubyipmi/ipmitool/commands/sensors.rb, line 50
def getsensors
  options["cmdargs"] = "sensor"
  value = runcmd
  options.delete_notify("cmdargs")
  @result
end
list() click to toggle source
# File lib/rubyipmi/ipmitool/commands/sensors.rb, line 14
def list
  @sensors ||= parse(getsensors)
end
names() click to toggle source
# File lib/rubyipmi/ipmitool/commands/sensors.rb, line 22
def names
  list.keys
end
refresh() click to toggle source
# File lib/rubyipmi/ipmitool/commands/sensors.rb, line 9
def refresh
  @sensors = nil
  list
end
templist(refreshdata=false) click to toggle source

returns a hash of sensors where each key is the name of the sensor and the value is the sensor

# File lib/rubyipmi/ipmitool/commands/sensors.rb, line 39
def templist(refreshdata=false)
  refresh if refreshdata
  tlist = {}
  list.each do | name , sensor |
    if sensor[:unit] =~ /.*degree.*/ || name =~ /.*temp.*/
      tlist[name] = sensor
    end
  end
  return tlist
end

Private Instance Methods

method_missing(method, *args, &block) click to toggle source
# File lib/rubyipmi/ipmitool/commands/sensors.rb, line 59
def method_missing(method, *args, &block)
  if not list.has_key?(method.to_s)
    raise NoMethodError
  else
    list[method.to_s]
  end
end
parse(data) click to toggle source
# File lib/rubyipmi/ipmitool/commands/sensors.rb, line 67
def parse(data)
  sensorlist = {}
  if ! data.nil?
    data.lines.each do | line|
      # skip the header
      sensor = Sensor.new(line)
      sensorlist[sensor[:name]] = sensor
    end
  end
  return sensorlist
end