Class: Nagios::Promoo::Opennebula::Probes::HostErrorProbe

Inherits:
BaseProbe
  • Object
show all
Defined in:
lib/nagios/promoo/opennebula/probes/host_error_probe.rb

Overview

Probe for checking ONe for ERRORs on hosts.

Author:

Constant Summary collapse

ERROR_KEYWORD =
'ERROR'.freeze

Instance Attribute Summary

Attributes inherited from BaseProbe

#options

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseProbe

#client, #initialize

Constructor Details

This class inherits a constructor from Nagios::Promoo::Opennebula::Probes::BaseProbe

Class Method Details

.declarationObject



21
22
23
# File 'lib/nagios/promoo/opennebula/probes/host_error_probe.rb', line 21

def declaration
  'host_error'
end

.descriptionObject



13
14
15
# 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

.optionsObject



17
18
19
# File 'lib/nagios/promoo/opennebula/probes/host_error_probe.rb', line 17

def options
  []
end

.runnable?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/nagios/promoo/opennebula/probes/host_error_probe.rb', line 25

def runnable?
  true
end

Instance Method Details

#run(_args = []) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
# 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