class Nagios::Promoo::Opennebula::Probes::HostErrorProbe

Probe for checking ONe for ERRORs on hosts.

@author Boris Parak <parak@cesnet.cz>

Constants

ERROR_KEYWORD

Public Class Methods

declaration() click to toggle source
# File lib/nagios/promoo/opennebula/probes/host_error_probe.rb, line 21
def declaration
  'host_error'
end
description() click to toggle source
# File lib/nagios/promoo/opennebula/probes/host_error_probe.rb, line 13
def description
  ['host-error', 'Run a probe checking for ERRORs on hosts']
end
options() click to toggle source
# File lib/nagios/promoo/opennebula/probes/host_error_probe.rb, line 17
def options
  []
end
runnable?() click to toggle source
# File lib/nagios/promoo/opennebula/probes/host_error_probe.rb, line 25
def runnable?
  true
end

Public Instance Methods

run(_args = []) click to toggle source
# File lib/nagios/promoo/opennebula/probes/host_error_probe.rb, line 32
def run(_args = [])
  Timeout.timeout(options[:timeout]) do
    errors = host_pool.select { |host| errored?(host) }
    errors.map! { |host| host['NAME'] }
    raise "HOSTs #{errors.inspect} are in state #{ERROR_KEYWORD}" if errors.count > 0
  end

  puts 'HOSTERR OK - Everything is hunky-dory'
rescue => ex
  puts "HOSTERR CRITICAL - #{ex.message}"
  puts ex.backtrace if options[:debug]
  exit 2
end

Private Instance Methods

errored?(host) click to toggle source
# File lib/nagios/promoo/opennebula/probes/host_error_probe.rb, line 56
def errored?(host)
  host.state_str == ERROR_KEYWORD
end
host_pool() click to toggle source
# File lib/nagios/promoo/opennebula/probes/host_error_probe.rb, line 48
def host_pool
  host_pool = OpenNebula::HostPool.new(client)
  rc = host_pool.info
  raise rc.message if OpenNebula.is_error?(rc)

  host_pool
end