Class: Rubyipmi::Ipmitool::Sensors

Inherits:
BaseCommand show all
Defined in:
lib/rubyipmi/ipmitool/commands/sensors.rb

Instance Attribute Summary

Attributes inherited from BaseCommand

#cmd, #lastcall, #max_retry_count, #options, #passfile, #result

Instance Method Summary collapse

Methods inherited from BaseCommand

#find_fix, #makecommand, #max_retry_count, #setpass

Methods inherited from BaseCommand

#dump_command, #find_fix, #locate_command, #logger, #makecommand, #removepass, #run, #runcmd, #setpass, #update, #validate_status

Constructor Details

#initialize(opts = ObservableHash.new) ⇒ Sensors

Returns a new instance of Sensors.



5
6
7
# File 'lib/rubyipmi/ipmitool/commands/sensors.rb', line 5

def initialize(opts = ObservableHash.new)
  super("ipmitool", opts)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object (private)



59
60
61
62
63
64
65
# 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

Instance Method Details

#countObject



18
19
20
# File 'lib/rubyipmi/ipmitool/commands/sensors.rb', line 18

def count
  list.count
end

#fanlist(refreshdata = false) ⇒ Object

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



27
28
29
30
31
32
33
34
35
36
# 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

#getsensorsObject



50
51
52
53
54
55
# File 'lib/rubyipmi/ipmitool/commands/sensors.rb', line 50

def getsensors
  options["cmdargs"] = "sensor"
  value = runcmd
  options.delete_notify("cmdargs")
  @result
end

#listObject



14
15
16
# File 'lib/rubyipmi/ipmitool/commands/sensors.rb', line 14

def list
  @sensors ||= parse(getsensors)
end

#namesObject



22
23
24
# File 'lib/rubyipmi/ipmitool/commands/sensors.rb', line 22

def names
  list.keys
end

#refreshObject



9
10
11
12
# File 'lib/rubyipmi/ipmitool/commands/sensors.rb', line 9

def refresh
  @sensors = nil
  list
end

#templist(refreshdata = false) ⇒ Object

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



39
40
41
42
43
44
45
46
47
48
# 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