Class: Riemann::Tools::Hwmon::Device

Inherits:
Object
  • Object
show all
Defined in:
lib/riemann/tools/hwmon.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hwmon, type, number) ⇒ Device

Returns a new instance of Device.



14
15
16
17
18
19
20
21
22
# File 'lib/riemann/tools/hwmon.rb', line 14

def initialize(hwmon, type, number)
  @hwmon = hwmon
  @type = type
  @number = number

  @crit = scale(read_hwmon_i('crit'))
  @lcrit = scale(read_hwmon_i('lcrit'))
  @service = ['hwmon', read_hwmon_file('name'), read_hwmon_s('label')].compact.join(' ')
end

Instance Attribute Details

#critObject (readonly)

Returns the value of attribute crit.



12
13
14
# File 'lib/riemann/tools/hwmon.rb', line 12

def crit
  @crit
end

#hwmonObject (readonly)

Returns the value of attribute hwmon.



12
13
14
# File 'lib/riemann/tools/hwmon.rb', line 12

def hwmon
  @hwmon
end

#lcritObject (readonly)

Returns the value of attribute lcrit.



12
13
14
# File 'lib/riemann/tools/hwmon.rb', line 12

def lcrit
  @lcrit
end

#numberObject (readonly)

Returns the value of attribute number.



12
13
14
# File 'lib/riemann/tools/hwmon.rb', line 12

def number
  @number
end

#serviceObject (readonly)

Returns the value of attribute service.



12
13
14
# File 'lib/riemann/tools/hwmon.rb', line 12

def service
  @service
end

#typeObject (readonly)

Returns the value of attribute type.



12
13
14
# File 'lib/riemann/tools/hwmon.rb', line 12

def type
  @type
end

Instance Method Details

#inputObject



24
25
26
# File 'lib/riemann/tools/hwmon.rb', line 24

def input
  read_hwmon_i('input')
end

#reportObject



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/riemann/tools/hwmon.rb', line 28

def report
  value = scale(input)

  state = :ok
  state = :critical if crit && value >= crit
  state = :critical if lcrit && value <= lcrit
  {
    service: service,
    state: state,
    metric: value,
    description: fromat_input(value),
  }
end