Class: Riemann::Tools::Hwmon
- Inherits:
-
Object
- Object
- Riemann::Tools::Hwmon
- Includes:
- Riemann::Tools
- Defined in:
- lib/riemann/tools/hwmon.rb
Defined Under Namespace
Classes: Device
Constant Summary
Constants included from Riemann::Tools
Instance Attribute Summary collapse
-
#devices ⇒ Object
readonly
Returns the value of attribute devices.
Attributes included from Riemann::Tools
Instance Method Summary collapse
-
#initialize ⇒ Hwmon
constructor
A new instance of Hwmon.
- #poll_devices ⇒ Object
- #tick ⇒ Object
Methods included from Riemann::Tools
#attributes, #endpoint_name, included, #options, #report, #riemann, #run
Constructor Details
#initialize ⇒ Hwmon
Returns a new instance of Hwmon.
87 88 89 90 91 |
# File 'lib/riemann/tools/hwmon.rb', line 87 def initialize super @devices = poll_devices end |
Instance Attribute Details
#devices ⇒ Object (readonly)
Returns the value of attribute devices.
85 86 87 |
# File 'lib/riemann/tools/hwmon.rb', line 85 def devices @devices end |
Instance Method Details
#poll_devices ⇒ Object
93 94 95 96 97 98 99 100 101 102 |
# File 'lib/riemann/tools/hwmon.rb', line 93 def poll_devices res = [] Dir['/sys/class/hwmon/hwmon[0-9]*/{in,fan,temp,curr,power,energy,humidity}[0-9]*_input'].each do |filename| m = filename.match(%r{/sys/class/hwmon/hwmon(\d+)/([[:alpha:]]+)(\d+)_input}) res << Device.new(m[1].to_i, m[2].to_sym, m[3].to_i) end res end |
#tick ⇒ Object
104 105 106 107 108 |
# File 'lib/riemann/tools/hwmon.rb', line 104 def tick devices.each do |device| report(device.report) end end |