Class: Nagios::Promoo::Occi::Probes::CategoriesProbe
- Inherits:
-
BaseProbe
- Object
- BaseProbe
- Nagios::Promoo::Occi::Probes::CategoriesProbe
show all
- Defined in:
- lib/nagios/promoo/occi/probes/categories_probe.rb
Overview
Probe for checking OCCI categories declared by endpoints.
Instance Attribute Summary
Attributes inherited from BaseProbe
#options
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from BaseProbe
#client, #initialize
Class Method Details
.declaration ⇒ Object
38
39
40
|
# File 'lib/nagios/promoo/occi/probes/categories_probe.rb', line 38
def declaration
'categories'
end
|
.description ⇒ Object
15
16
17
|
# File 'lib/nagios/promoo/occi/probes/categories_probe.rb', line 15
def description
['categories', 'Run a probe checking for mandatory OCCI category definitions']
end
|
.options ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/nagios/promoo/occi/probes/categories_probe.rb', line 19
def options
[
[
:optional,
{
type: :array, default: [],
desc: 'Identifiers of optional categories (optional by force)'
}
],
[
:check_location,
{
type: :boolean, default: false,
desc: 'Verify declared REST locations for INFRA resources'
}
]
]
end
|
.runnable? ⇒ Boolean
42
43
44
|
# File 'lib/nagios/promoo/occi/probes/categories_probe.rb', line 42
def runnable?
true
end
|
Instance Method Details
#run(_args = []) ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/nagios/promoo/occi/probes/categories_probe.rb', line 47
def run(_args = [])
categories = all_categories
categories -= options[:optional] if options[:optional]
Timeout.timeout(options[:timeout]) do
categories.each do |cat|
raise "#{cat.inspect} is missing" unless client.model.get_by_id(cat, true)
next unless options[:check_location] && infra_kinds.include?(cat)
begin
client.list(cat)
rescue => ex
raise "Failed to verify declared REST location for #{cat.inspect} (#{ex.message})"
end
end
end
puts 'CATEGORIES OK - All specified OCCI categories were found'
rescue => ex
puts "CATEGORIES CRITICAL - #{ex.message}"
puts ex.backtrace if options[:debug]
exit 2
end
|