Class: Riemann::Tools::Zpool

Inherits:
Object
  • Object
show all
Includes:
Riemann::Tools
Defined in:
lib/riemann/tools/zpool.rb

Constant Summary

Constants included from Riemann::Tools

VERSION

Instance Attribute Summary

Attributes included from Riemann::Tools

#argv

Instance Method Summary collapse

Methods included from Riemann::Tools

#attributes, #endpoint_name, included, #initialize, #options, #report, #riemann, #run

Instance Method Details

#tickObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/riemann/tools/zpool.rb', line 12

def tick
  output, status = Open3.capture2e('zpool status -x')

  state = if status.success?
            case output
            when "all pools are healthy\n" then 'ok'
            when /state: (DEGRADED|FAULTED)/ then 'critical'
            else
              'warning'
            end
          else
            'critical'
          end

  report(
    service: 'zpool health',
    description: output,
    state: state,
  )
rescue Errno::ENOENT => e
  report(
    service: 'zpool health',
    description: e.message,
    state: 'critical',
  )
end