Class: Rubyipmi::Freeipmi::Sensors
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- BaseCommand
- Rubyipmi::Freeipmi::Sensors
- Defined in:
- lib/rubyipmi/freeipmi/commands/sensors.rb
Instance Attribute Summary
Attributes inherited from BaseCommand
#cmd, #lastcall, #max_retry_count, #options, #passfile, #result
Instance Method Summary collapse
- #count ⇒ Object
-
#fanlist(refreshdata = false) ⇒ Object
returns a hash of fan sensors where the key is fan name and value is the sensor.
- #getsensors ⇒ Object
-
#initialize(opts = ObservableHash.new) ⇒ Sensors
constructor
A new instance of Sensors.
- #list ⇒ Object
- #names ⇒ Object
- #refresh ⇒ Object
-
#templist(refreshdata = false) ⇒ Object
returns a hash of sensors where each key is the name of the sensor and the value is the sensor.
Methods inherited from BaseCommand
#find_fix, #makecommand, #max_retry_count, #setpass, #validate_status
Methods inherited from BaseCommand
#dump_command, #find_fix, #locate_command, #makecommand, #removepass, #run, #runcmd, #setpass, #update, #validate_status
Constructor Details
#initialize(opts = ObservableHash.new) ⇒ Sensors
Returns a new instance of Sensors.
5 6 7 8 9 10 |
# File 'lib/rubyipmi/freeipmi/commands/sensors.rb', line 5 def initialize(opts = ObservableHash.new) super("ipmi-sensors", opts) ["no-header-output"] = false ["output-sensor-state"] = false ["entity-sensor-names"] = false end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object (private)
60 61 62 63 64 65 66 |
# File 'lib/rubyipmi/freeipmi/commands/sensors.rb', line 60 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
#count ⇒ Object
21 22 23 |
# File 'lib/rubyipmi/freeipmi/commands/sensors.rb', line 21 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
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rubyipmi/freeipmi/commands/sensors.rb', line 30 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 ⇒ Object
53 54 55 56 |
# File 'lib/rubyipmi/freeipmi/commands/sensors.rb', line 53 def getsensors value = runcmd return @result end |
#list ⇒ Object
17 18 19 |
# File 'lib/rubyipmi/freeipmi/commands/sensors.rb', line 17 def list @sensors ||= parse(getsensors) end |
#names ⇒ Object
25 26 27 |
# File 'lib/rubyipmi/freeipmi/commands/sensors.rb', line 25 def names list.keys end |
#refresh ⇒ Object
12 13 14 15 |
# File 'lib/rubyipmi/freeipmi/commands/sensors.rb', line 12 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
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/rubyipmi/freeipmi/commands/sensors.rb', line 42 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 |