Class: Nagios::Promoo::Opennebula::Probes::VirtualMachineFailsProbe

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

Overview

Probe for checking ONe for FAILED virtual machines.

Author:

Constant Summary collapse

FAIL_KEYWORD =
'FAILURE'.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/virtual_machine_fails_probe.rb', line 21

def declaration
  'virtual_machine_fails'
end

.descriptionObject



13
14
15
# File 'lib/nagios/promoo/opennebula/probes/virtual_machine_fails_probe.rb', line 13

def description
  ['virtual-machine-fails', 'Run a probe checking for FAILED virtual machines']
end

.optionsObject



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

def options
  []
end

.runnable?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/nagios/promoo/opennebula/probes/virtual_machine_fails_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/virtual_machine_fails_probe.rb', line 32

def run(_args = [])
  Timeout.timeout(options[:timeout]) do
    fails = virtual_machine_pool.select { |vm| failed?(vm) }
    fails.map!(&:id)
    raise "Virtual machines #{fails.inspect} are in a FAILED state" if fails.count > 0
  end

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