nagios-promoo 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/nagios/promoo/appdb/probes/appliances_probe.rb +1 -1
- data/lib/nagios/promoo/appdb/probes/sizes_probe.rb +1 -1
- data/lib/nagios/promoo/appdb/probes/vmcatcher_probe.rb +123 -0
- data/lib/nagios/promoo/occi/probes/compute_probe.rb +4 -4
- data/lib/nagios/promoo/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f7f2c421b78082e85f93d8b87f0a462098d0529
|
4
|
+
data.tar.gz: 7e9a8dfbdbae3725060df61d23a102d16371b799
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd841214286f739bf7f3acfab1c45507d0b59897e6f13889640be748a80dc3df8657b7b08e36d38fd38158c76f53145dad2baa0535e5ce4eb82139027ad446fa
|
7
|
+
data.tar.gz: f355d7bd0cbeae0643d7133b31f19843b2ebd12585896593906a125d56e5d5ce6eeb762812a24bf1f194c9a7f3b25145d2e3ddbc0acb52c8e0aae07fbf048da0
|
@@ -0,0 +1,123 @@
|
|
1
|
+
# Internal deps
|
2
|
+
require File.join(File.dirname(__FILE__), 'base_probe')
|
3
|
+
|
4
|
+
class Nagios::Promoo::Appdb::Probes::VmcatcherProbe < Nagios::Promoo::Appdb::Probes::BaseProbe
|
5
|
+
class << self
|
6
|
+
def description
|
7
|
+
['vmcatcher', 'Run a probe checking consistency between a vmcatcher image list and available appliances (via AppDB)']
|
8
|
+
end
|
9
|
+
|
10
|
+
def options
|
11
|
+
[
|
12
|
+
[:vo, { type: :string, required: true, desc: 'Virtual Organization name (used to select the appropriate VO-wide image list)' }],
|
13
|
+
[:token, { type: :string, required: true, desc: 'AppDB authentication token (used to access the VO-wide image list)' }],
|
14
|
+
[:missing_critical, { type: :numeric, default: 2, desc: 'Number of missing appliances to be considered CRITICAL' }],
|
15
|
+
[:outdated_critical, { type: :numeric, default: 5, desc: 'Number of outdated appliances to be considered CRITICAL' }],
|
16
|
+
]
|
17
|
+
end
|
18
|
+
|
19
|
+
def declaration
|
20
|
+
"vmcatcher"
|
21
|
+
end
|
22
|
+
|
23
|
+
def runnable?; true; end
|
24
|
+
end
|
25
|
+
|
26
|
+
IMAGE_LIST_TEMPLATE = "https://$$TOKEN$$:x-oauth-basic@vmcaster.appdb.egi.eu/store/vo/$$VO$$/image.list"
|
27
|
+
IMAGE_LIST_BOUNDARY_REGEXP = /boundary="(?<prefix>-+)(?<id>[[:alnum:]]+)"/
|
28
|
+
|
29
|
+
def run(options, args = [])
|
30
|
+
results = begin
|
31
|
+
Timeout::timeout(options[:timeout]) { check_vmc_sync(options) }
|
32
|
+
rescue => ex
|
33
|
+
puts "VMCATCHER CRITICAL - #{ex.message}"
|
34
|
+
puts ex.backtrace if options[:debug]
|
35
|
+
exit 2
|
36
|
+
end
|
37
|
+
|
38
|
+
if results[:missing].count >= options[:missing_critical]
|
39
|
+
puts "VMCATCHER CRITICAL - #{results[:missing].count} appliance(s) in #{options[:vo].inspect} missing"
|
40
|
+
exit 2
|
41
|
+
end
|
42
|
+
|
43
|
+
## TODO: checking for outdated appliances is not working yet
|
44
|
+
##
|
45
|
+
# if results[:outdated].count >= options[:outdated_critical]
|
46
|
+
# puts "VMCATCHER CRITICAL - #{results[:outdated].count} appliance(s) in #{options[:vo].inspect} outdated"
|
47
|
+
# exit 2
|
48
|
+
# end
|
49
|
+
#
|
50
|
+
# if results[:outdated].count > 0
|
51
|
+
# puts "VMCATCHER WARNING - #{results[:outdated].count} appliances in #{options[:vo].inspect} outdated"
|
52
|
+
# exit 1
|
53
|
+
# end
|
54
|
+
|
55
|
+
puts "VMCATCHER OK - All appliances registered in #{options[:vo].inspect} are available [#{results[:expected].count}]"
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def check_vmc_sync(options)
|
61
|
+
results = { found: [], outdated: [], missing: [], expected: [] }
|
62
|
+
|
63
|
+
vo_list(options).each do |mpuri|
|
64
|
+
mpuri_versionless = versionless_mpuri(mpuri)
|
65
|
+
mpuri_normalized = normalize_mpuri(mpuri)
|
66
|
+
results[:expected] << mpuri_versionless
|
67
|
+
|
68
|
+
if normalized_appliances(options).include?(mpuri_normalized)
|
69
|
+
results[:found] << mpuri_normalized
|
70
|
+
elsif versionless_appliances(options).include?(mpuri_versionless)
|
71
|
+
results[:found] << mpuri_versionless
|
72
|
+
results[:outdated] << mpuri_versionless
|
73
|
+
else
|
74
|
+
results[:missing] << mpuri_versionless
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
results
|
79
|
+
end
|
80
|
+
|
81
|
+
def provider_appliances(options)
|
82
|
+
images = [appdb_provider(options)['image']].flatten.compact
|
83
|
+
images.collect { |image| image['mp_uri'] }.reject { |mpuri| mpuri.blank? }
|
84
|
+
end
|
85
|
+
|
86
|
+
def normalized_appliances(options)
|
87
|
+
provider_appliances(options).collect { |mpuri| normalize_mpuri(mpuri) }
|
88
|
+
end
|
89
|
+
|
90
|
+
def versionless_appliances(options)
|
91
|
+
provider_appliances(options).collect { |mpuri| versionless_mpuri(mpuri) }
|
92
|
+
end
|
93
|
+
|
94
|
+
def vo_list(options)
|
95
|
+
return @mpuris if @mpuris
|
96
|
+
|
97
|
+
list = nil
|
98
|
+
begin
|
99
|
+
list_url = IMAGE_LIST_TEMPLATE.gsub('$$TOKEN$$', options[:token]).gsub('$$VO$$', options[:vo])
|
100
|
+
response = HTTParty.get(list_url)
|
101
|
+
fail "Could not get a VO-wide image list" \
|
102
|
+
"from #{list_url.inspect} [#{response.code}]" unless response.success?
|
103
|
+
|
104
|
+
list = JSON.parse(OpenSSL::PKCS7.read_smime(response.parsed_response).data) # TODO: validate the signature?
|
105
|
+
fail "AppDB image list #{list_url.inspect} does " \
|
106
|
+
"not contain images" unless list && list['hv:imagelist'] && list['hv:imagelist']['hv:images']
|
107
|
+
rescue => ex
|
108
|
+
puts "VMCATCHER UNKNOWN - #{ex.message}"
|
109
|
+
puts ex.backtrace if options[:debug]
|
110
|
+
exit 3
|
111
|
+
end
|
112
|
+
|
113
|
+
@mpuris = list['hv:imagelist']['hv:images'].collect { |im| im['hv:image']['ad:mpuri'] }.reject { |uri| uri.blank? }
|
114
|
+
end
|
115
|
+
|
116
|
+
def normalize_mpuri(mpuri)
|
117
|
+
mpuri.gsub(/\/+$/, '')
|
118
|
+
end
|
119
|
+
|
120
|
+
def versionless_mpuri(mpuri)
|
121
|
+
normalize_mpuri(mpuri).gsub(/:\d+$/, '')
|
122
|
+
end
|
123
|
+
end
|
@@ -110,9 +110,9 @@ class Nagios::Promoo::Occi::Probes::ComputeProbe < Nagios::Promoo::Occi::Probes:
|
|
110
110
|
|
111
111
|
def appdb_appliance(options)
|
112
112
|
appliance = nil
|
113
|
-
appliance = appdb_provider(options)['image'].select do |image|
|
113
|
+
appliance = [appdb_provider(options)['image']].flatten.compact.select do |image|
|
114
114
|
image['mp_uri'] && (normalize_mpuri(image['mp_uri']) == normalize_mpuri(options[:mpuri]))
|
115
|
-
end.first
|
115
|
+
end.first
|
116
116
|
fail "Site does not have an appliance with MPURI "\
|
117
117
|
"#{normalize_mpuri(options[:mpuri]).inspect} published in AppDB" if appliance.blank?
|
118
118
|
|
@@ -121,12 +121,12 @@ class Nagios::Promoo::Occi::Probes::ComputeProbe < Nagios::Promoo::Occi::Probes:
|
|
121
121
|
|
122
122
|
def appdb_smallest_size(options)
|
123
123
|
sizes = []
|
124
|
-
appdb_provider(options)['template'].each do |template|
|
124
|
+
[appdb_provider(options)['template']].flatten.compact.each do |template|
|
125
125
|
sizes << [
|
126
126
|
template['resource_name'].split('#').last,
|
127
127
|
template['main_memory_size'].to_i + (template['physical_cpus'].to_i * CPU_SUM_WEIGHT)
|
128
128
|
]
|
129
|
-
end
|
129
|
+
end
|
130
130
|
fail "No appliance sizes available in AppDB" if sizes.blank?
|
131
131
|
sizes.sort! { |x,y| x.last <=> y.last }
|
132
132
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nagios-promoo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Boris Parak
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: occi-api
|
@@ -241,6 +241,7 @@ files:
|
|
241
241
|
- lib/nagios/promoo/appdb/probes/appliances_probe.rb
|
242
242
|
- lib/nagios/promoo/appdb/probes/base_probe.rb
|
243
243
|
- lib/nagios/promoo/appdb/probes/sizes_probe.rb
|
244
|
+
- lib/nagios/promoo/appdb/probes/vmcatcher_probe.rb
|
244
245
|
- lib/nagios/promoo/appdb/version.rb
|
245
246
|
- lib/nagios/promoo/master.rb
|
246
247
|
- lib/nagios/promoo/occi/.keep
|