Class: Nagios::Promoo::Opennebula::Probes::VirtualMachineProbe
- Inherits:
-
BaseProbe
- Object
- BaseProbe
- Nagios::Promoo::Opennebula::Probes::VirtualMachineProbe
- Defined in:
- lib/nagios/promoo/opennebula/probes/virtual_machine_probe.rb
Overview
Probe for checking VM instantiation via ONe RPC2.
Constant Summary collapse
- VM_NAME_PREFIX =
'nagios-promoo'.freeze
Instance Attribute Summary
Attributes inherited from BaseProbe
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from BaseProbe
Constructor Details
This class inherits a constructor from Nagios::Promoo::Opennebula::Probes::BaseProbe
Class Method Details
.declaration ⇒ Object
43 44 45 |
# File 'lib/nagios/promoo/opennebula/probes/virtual_machine_probe.rb', line 43 def declaration 'virtual_machine' end |
.description ⇒ Object
13 14 15 |
# File 'lib/nagios/promoo/opennebula/probes/virtual_machine_probe.rb', line 13 def description ['virtual-machine', 'Run a probe instantiating a test instance in OpenNebula'] end |
.options ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/nagios/promoo/opennebula/probes/virtual_machine_probe.rb', line 17 def [ [ :template, { type: :string, default: 'monitoring', desc: 'Name referencing a template used for monitoring purposes' } ], [ :vm_timeout, { type: :numeric, default: 180, desc: 'Timeout for VM instantiation (in seconds)' } ], [ :cleanup, { type: :boolean, default: true, desc: 'Perform clean-up before launching a new instance' } ] ] end |
.runnable? ⇒ Boolean
47 48 49 |
# File 'lib/nagios/promoo/opennebula/probes/virtual_machine_probe.rb', line 47 def runnable? true end |
Instance Method Details
#run(_args = []) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/nagios/promoo/opennebula/probes/virtual_machine_probe.rb', line 54 def run(_args = []) if [:timeout] <= [:vm_timeout] raise "Timeout (#{[:timeout]}) must be higher than "\ "vm-timeout (#{[:vm_timeout]}) " end @_virtual_machine = nil Timeout.timeout([:timeout]) do cleanup if [:cleanup] create wait4running end puts "VirtualMachine OK - Instance #{@_virtual_machine.id.inspect} of template "\ "#{[:template].inspect} successfully created & cleaned up" rescue => ex puts "VirtualMachine CRITICAL - #{ex.}" puts ex.backtrace if [:debug] exit 2 ensure begin cleanup @_virtual_machine unless @_virtual_machine.blank? rescue => ex puts "VirtualMachine CRITICAL - #{ex.}" puts ex.backtrace if [:debug] exit 2 end end |