class Riemann::Tools::Zpool

Public Instance Methods

tick() click to toggle source
# 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