nagios-promoo 1.6.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/History.md +5 -0
- data/lib/nagios/promoo/appdb/probes/appliances_probe.rb +14 -14
- data/lib/nagios/promoo/appdb/probes/base_probe.rb +41 -19
- data/lib/nagios/promoo/appdb/probes/sizes_probe.rb +3 -12
- data/lib/nagios/promoo/appdb/probes/sync_probe.rb +15 -25
- data/lib/nagios/promoo/appdb/version.rb +1 -1
- data/lib/nagios/promoo/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 776caf450626d472aa75ddd72a1cb24ed231b858
|
4
|
+
data.tar.gz: c1833207e57564af55bd7363f7ab0e19872a269a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62f74f848f0de94c5f2b3c78477a0b5fc153c59ed0f8688daee0dc5ea66c307f7e9fc9eb3e4cb3492502d5f1dba011a5ecc58e588b4fbf9db10b9c81769dedd7
|
7
|
+
data.tar.gz: 340a9af73318b73f8c61ee64ca1d0a1fdd4bff45ba58d80eac594273aa635059bb52665a377ed9290c2132d6be0307c1a045d1041215d419ca8191df332170df
|
data/History.md
CHANGED
@@ -15,7 +15,16 @@ module Nagios
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def options
|
18
|
-
[
|
18
|
+
[
|
19
|
+
[
|
20
|
+
:vo,
|
21
|
+
{
|
22
|
+
type: :string,
|
23
|
+
required: true,
|
24
|
+
desc: 'Virtual Organization name (used to select the appropriate set of appliances)'
|
25
|
+
}
|
26
|
+
]
|
27
|
+
]
|
19
28
|
end
|
20
29
|
|
21
30
|
def declaration
|
@@ -28,27 +37,18 @@ module Nagios
|
|
28
37
|
end
|
29
38
|
|
30
39
|
def run(_args = [])
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
if @_count < 1
|
36
|
-
puts 'APPLIANCES CRITICAL - No appliances found in AppDB'
|
40
|
+
count = Timeout.timeout(options[:timeout]) { appliances_by_endpoint(options[:vo]).count }
|
41
|
+
if count < 1
|
42
|
+
puts "APPLIANCES CRITICAL - No appliances found for VO #{options[:vo]} in AppDB"
|
37
43
|
exit 2
|
38
44
|
end
|
39
45
|
|
40
|
-
puts "APPLIANCES OK - Found #{
|
46
|
+
puts "APPLIANCES OK - Found #{count} appliances for VO #{options[:vo]} in AppDB"
|
41
47
|
rescue => ex
|
42
48
|
puts "APPLIANCES UNKNOWN - #{ex.message}"
|
43
49
|
puts ex.backtrace if options[:debug]
|
44
50
|
exit 3
|
45
51
|
end
|
46
|
-
|
47
|
-
private
|
48
|
-
|
49
|
-
def check_appliances
|
50
|
-
@_count = [appdb_provider['provider:image']].flatten.compact.count
|
51
|
-
end
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
@@ -12,39 +12,61 @@ module Nagios
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
|
15
|
+
APPDB_IS_URL = 'http://is.marie.hellasgrid.gr/graphql'.freeze
|
16
|
+
DEFAULT_HEADERS = { 'Content-Type' => 'application/json' }.freeze
|
17
|
+
GQL_SIZES_BY_ENDPOINT = %|
|
18
|
+
{
|
19
|
+
siteServiceTemplates(
|
20
|
+
filter: { service: { endpointURL: { eq: "$$ENDPOINT$$" } } }, limit: 1000
|
21
|
+
) {
|
22
|
+
items { resourceID }
|
23
|
+
}
|
24
|
+
}
|
25
|
+
|.freeze
|
26
|
+
GQL_APPLIANCES_BY_ENDPOINT = %|
|
27
|
+
{
|
28
|
+
siteServiceImages(
|
29
|
+
filter: { imageVoVmiInstanceVO: { eq: "$$VO$$" }, service: { endpointURL: { eq: "$$ENDPOINT$$" } } }, limit: 1000
|
30
|
+
) {
|
31
|
+
items { applicationEnvironmentRepository applicationEnvironmentAppVersion }
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|.freeze
|
16
35
|
|
17
|
-
attr_reader :options
|
36
|
+
attr_reader :options, :endpoint
|
18
37
|
|
19
38
|
def initialize(options)
|
20
39
|
@options = options
|
40
|
+
@endpoint = options[:endpoint].gsub(%r{/+$}, '')
|
21
41
|
end
|
22
42
|
|
23
|
-
def
|
24
|
-
return @
|
43
|
+
def sizes_by_endpoint
|
44
|
+
return @_sizes if @_sizes
|
25
45
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
raise "Could not locate site by endpoint #{options[:endpoint].inspect} in AppDB" unless @_provider
|
46
|
+
query = GQL_SIZES_BY_ENDPOINT.gsub('$$ENDPOINT$$', endpoint)
|
47
|
+
@_sizes = make(query)['data']['siteServiceTemplates']['items']
|
48
|
+
raise "Could not locate sizes from endpoint #{endpoint.inspect} in AppDB" unless @_sizes
|
30
49
|
|
31
|
-
@
|
50
|
+
@_sizes
|
32
51
|
end
|
33
52
|
|
34
|
-
|
53
|
+
def appliances_by_endpoint(vo)
|
54
|
+
return @_appliances if @_appliances
|
35
55
|
|
36
|
-
|
37
|
-
|
38
|
-
raise "Could not
|
39
|
-
raise 'Response from AppDB has unexpected structure' unless valid_response?(response.parsed_response)
|
56
|
+
query = GQL_APPLIANCES_BY_ENDPOINT.gsub('$$ENDPOINT$$', endpoint).gsub('$$VO$$', vo)
|
57
|
+
@_appliances = make(query)['data']['siteServiceImages']['items']
|
58
|
+
raise "Could not locate appliances from endpoint #{endpoint.inspect} in AppDB" unless @_appliances
|
40
59
|
|
41
|
-
|
42
|
-
providers.delete_if { |prov| prov['provider:endpoint_url'].blank? }
|
60
|
+
@_appliances
|
43
61
|
end
|
44
62
|
|
45
|
-
|
46
|
-
|
47
|
-
|
63
|
+
private
|
64
|
+
|
65
|
+
def make(query)
|
66
|
+
response = HTTParty.post(APPDB_IS_URL, body: { query: query }.to_json, headers: DEFAULT_HEADERS)
|
67
|
+
raise "#{query.inspect} failed to get data from AppDB [HTTP #{response.code}]" unless response.success?
|
68
|
+
|
69
|
+
response.parsed_response
|
48
70
|
end
|
49
71
|
end
|
50
72
|
end
|
@@ -28,27 +28,18 @@ module Nagios
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def run(_args = [])
|
31
|
-
|
32
|
-
|
33
|
-
Timeout.timeout(options[:timeout]) { check_sizes }
|
34
|
-
|
35
|
-
if @_count < 1
|
31
|
+
count = Timeout.timeout(options[:timeout]) { sizes_by_endpoint.count }
|
32
|
+
if count < 1
|
36
33
|
puts 'SIZES CRITICAL - No size/flavor/resource templates found in AppDB'
|
37
34
|
exit 2
|
38
35
|
end
|
39
36
|
|
40
|
-
puts "SIZES OK - Found #{
|
37
|
+
puts "SIZES OK - Found #{count} size/flavor/resource templates in AppDB"
|
41
38
|
rescue => ex
|
42
39
|
puts "SIZES UNKNOWN - #{ex.message}"
|
43
40
|
puts ex.backtrace if options[:debug]
|
44
41
|
exit 3
|
45
42
|
end
|
46
|
-
|
47
|
-
private
|
48
|
-
|
49
|
-
def check_sizes
|
50
|
-
@_count = [appdb_provider['provider:template']].flatten.compact.count
|
51
|
-
end
|
52
43
|
end
|
53
44
|
end
|
54
45
|
end
|
@@ -104,42 +104,34 @@ module Nagios
|
|
104
104
|
mpuri_versionless = versionless_mpuri(hv_image['ad:mpuri'])
|
105
105
|
@_results[:expected] << mpuri_versionless
|
106
106
|
|
107
|
-
matching =
|
107
|
+
matching = appliances_by_endpoint(options[:vo]).detect do |appl|
|
108
|
+
versionless_mpuri(appl['applicationEnvironmentRepository']) == mpuri_versionless
|
109
|
+
end
|
110
|
+
|
108
111
|
unless matching
|
109
112
|
@_results[:missing] << mpuri_versionless
|
110
113
|
next
|
111
114
|
end
|
112
115
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
end
|
117
|
-
|
118
|
-
def provider_appliances
|
119
|
-
return @_appliances if @_appliances
|
120
|
-
|
121
|
-
@_appliances = [appdb_provider['provider:image']].flatten.compact
|
122
|
-
@_appliances.keep_if { |appliance| appliance['voname'] == options[:vo] }
|
123
|
-
@_appliances.reject { |appliance| appliance['mp_uri'].blank? }
|
116
|
+
unless hv_image['hv:version'] == matching['applicationEnvironmentAppVersion']
|
117
|
+
@_results[:outdated] << mpuri_versionless
|
118
|
+
end
|
124
119
|
|
125
|
-
|
126
|
-
appliance['mp_uri'] = versionless_mpuri(appliance['mp_uri'])
|
120
|
+
@_results[:found] << mpuri_versionless
|
127
121
|
end
|
128
|
-
|
129
|
-
@_appliances
|
130
122
|
end
|
131
123
|
|
132
124
|
def vo_list
|
133
125
|
return @_hv_images if @_hv_images
|
134
126
|
|
135
|
-
list = JSON.parse
|
136
|
-
raise
|
127
|
+
list = JSON.parse(pkcs7_data)
|
128
|
+
raise 'AppDB image list is empty or malformed' unless list && list['hv:imagelist']
|
137
129
|
|
138
130
|
list = list['hv:imagelist']
|
139
131
|
unless Time.parse(list['dc:date:expires']) > Time.now
|
140
|
-
raise
|
132
|
+
raise 'AppDB image list has expired'
|
141
133
|
end
|
142
|
-
raise "AppDB image list
|
134
|
+
raise "AppDB image list doesn't contain images" unless list['hv:images']
|
143
135
|
@_last_update = Time.parse(list['dc:date:created'])
|
144
136
|
|
145
137
|
@_hv_images = list['hv:images'].collect { |im| im['hv:image'] }
|
@@ -153,11 +145,9 @@ module Nagios
|
|
153
145
|
end
|
154
146
|
|
155
147
|
def retrieve_list
|
156
|
-
response = HTTParty.get
|
157
|
-
unless response.success?
|
158
|
-
|
159
|
-
"from #{list_url.inspect} [#{response.code}]"
|
160
|
-
end
|
148
|
+
response = HTTParty.get(list_url)
|
149
|
+
raise "Could not get an image list from AppDB [HTTP #{response.code}]" unless response.success?
|
150
|
+
|
161
151
|
response.parsed_response
|
162
152
|
end
|
163
153
|
|
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: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Boris Parak
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|