class Nagios::Promoo::Occi::Probes::MixinsProbe

Probe for checking OCCI mixins declared by sites.

@author Boris Parak <parak@cesnet.cz>

Constants

CONTEXT_MIXINS
INFRA_MIXINS

Public Class Methods

declaration() click to toggle source
# File lib/nagios/promoo/occi/probes/mixins_probe.rb, line 36
def declaration
  'mixins'
end
description() click to toggle source
# File lib/nagios/promoo/occi/probes/mixins_probe.rb, line 13
def description
  ['mixins', 'Run a probe checking for mandatory OCCI mixin definitions']
end
options() click to toggle source
# File lib/nagios/promoo/occi/probes/mixins_probe.rb, line 17
def options
  [
    [
      :mixins,
      {
        type: :string, enum: %w[infra context all],
        default: 'all', desc: 'Collection of mandatory mixins to check'
      }
    ],
    [
      :optional,
      {
        type: :array, default: [],
        desc: 'Identifiers of optional mixins (optional by force)'
      }
    ]
  ]
end
runnable?() click to toggle source
# File lib/nagios/promoo/occi/probes/mixins_probe.rb, line 40
def runnable?
  true
end

Public Instance Methods

run(_args = []) click to toggle source
# File lib/nagios/promoo/occi/probes/mixins_probe.rb, line 55
def run(_args = [])
  mixins = []
  mixins += INFRA_MIXINS if %w[infra all].include?(options[:mixins])
  mixins += CONTEXT_MIXINS if %w[context all].include?(options[:mixins])
  mixins -= options[:optional] if options[:optional]

  Timeout.timeout(options[:timeout]) do
    mixins.each { |mixin| raise "#{mixin.inspect} is missing" unless client.model.get_by_id(mixin, true) }
  end

  puts 'MIXINS OK - All specified OCCI mixins were found'
rescue => ex
  puts "MIXINS CRITICAL - #{ex.message}"
  puts ex.backtrace if options[:debug]
  exit 2
end