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, #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/freeipmi/commands/sensors.rb', line 5 def initialize(opts = ObservableHash.new) super("ipmi-sensors", opts) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object (private)
63 64 65 66 67 68 69 |
# File 'lib/rubyipmi/freeipmi/commands/sensors.rb', line 63 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
18 19 20 |
# File 'lib/rubyipmi/freeipmi/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/freeipmi/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 ⇒ Object
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/rubyipmi/freeipmi/commands/sensors.rb', line 50 def getsensors @options["no-header-output"] = false @options["output-sensor-state"] = false @options["entity-sensor-names"] = false value = runcmd @options.delete_notify('no-header-output') @options.delete_notify('output-sensor-state') @options.delete_notify('entity-sensor-names') @result end |
#list ⇒ Object
14 15 16 |
# File 'lib/rubyipmi/freeipmi/commands/sensors.rb', line 14 def list @sensors ||= parse(getsensors) end |
#names ⇒ Object
22 23 24 |
# File 'lib/rubyipmi/freeipmi/commands/sensors.rb', line 22 def names list.keys end |
#refresh ⇒ Object
9 10 11 12 |
# File 'lib/rubyipmi/freeipmi/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/freeipmi/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 |