nagios-promoo 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1e735c8510920fe9ed8dd4d200c31aca66a7771f
4
- data.tar.gz: c7ca40aa71dbf5291d3b975860518758bce65bee
3
+ metadata.gz: 03a43d2f650bc5bfa06dc735193c61b22ec16fba
4
+ data.tar.gz: f07fda7f6d2240c5e140509feeb05ab2b5c405d7
5
5
  SHA512:
6
- metadata.gz: 2e1ca3d2b6a99c7a34d19b06e2feecdc49e24aecb63c6a57ce526c5ab1858a0ffcb9ec4f9272b80162c801f2002170d1faea6f3bae6cb0b4d445c1b51cc17acd
7
- data.tar.gz: 9c15ac5874413491dcd88b478f71f681e71c796550bda663666b3ea38b0e4bd8c559f85513e8b0dbf867e7a00ffe96f4102792085b64d6c347839e56296ad71b
6
+ metadata.gz: 437c81a1847705426e476d597ed0e7744d463d3158c888db3b402340e374e1644ee74cc67c5782589f2719389e8fd950add0fa8ae2c3a28a73b9029e2b9fe8b4
7
+ data.tar.gz: 36d059ca5a98c910f570b1ae6ca376f25e104fb618f817f2931ee4f01f5406d77def52f9671ca33cbea62db23357af1a950fb9a84d9b329c75c2ca9388388349
@@ -11,8 +11,8 @@ class Nagios::Promoo::Appdb::Probes::VmcatcherProbe < Nagios::Promoo::Appdb::Pro
11
11
  [
12
12
  [:vo, { type: :string, required: true, desc: 'Virtual Organization name (used to select the appropriate VO-wide image list)' }],
13
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' }],
14
+ [:warning_after, { type: :numeric, default: 24, desc: 'A number of hours after list publication when missing or outdated appliances raise WARNING' }],
15
+ [:critical_after, { type: :numeric, default: 72, desc: 'A number of hours after list publication when missing or outdated appliances raise CRITICAL' }],
16
16
  ]
17
17
  end
18
18
 
@@ -31,22 +31,25 @@ class Nagios::Promoo::Appdb::Probes::VmcatcherProbe < Nagios::Promoo::Appdb::Pro
31
31
 
32
32
  Timeout::timeout(options[:timeout]) { check_vmc_sync }
33
33
 
34
- if @_results[:missing].count >= options[:missing_critical]
35
- puts "VMCATCHER CRITICAL - #{@_results[:missing].count} appliance(s) in #{options[:vo].inspect} missing"
36
- exit 2
37
- end
38
-
39
- if @_results[:outdated].count >= options[:outdated_critical]
40
- puts "VMCATCHER CRITICAL - #{@_results[:outdated].count} appliance(s) in #{options[:vo].inspect} outdated"
41
- exit 2
42
- end
34
+ wrong = @_results[:missing] + @_results[:outdated]
35
+ if wrong.any?
36
+ if (@_last_update + options[:critical_after].hours) < Time.now
37
+ puts "VMCATCHER CRITICAL - Appliance(s) #{wrong.inspect} missing " \
38
+ "or outdated in #{options[:vo].inspect} " \
39
+ "more than #{options[:critical_after]} hours after list publication [#{@_last_update}]"
40
+ exit 2
41
+ end
43
42
 
44
- if @_results[:outdated].count > 0
45
- puts "VMCATCHER WARNING - #{@_results[:outdated].count} appliances in #{options[:vo].inspect} outdated"
46
- exit 1
43
+ if (@_last_update + options[:warning_after].hours) < Time.now
44
+ puts "VMCATCHER WARNING - Appliance(s) #{wrong.inspect} missing " \
45
+ "or outdated in #{options[:vo].inspect} " \
46
+ "more than #{options[:warning_after]} hours after list publication [#{@_last_update}]"
47
+ exit 1
48
+ end
47
49
  end
48
50
 
49
- puts "VMCATCHER OK - All appliances registered in #{options[:vo].inspect} are available [#{@_results[:expected].count}]"
51
+ puts "VMCATCHER OK - All appliances registered in #{options[:vo].inspect} " \
52
+ "are available [#{@_results[:expected].count}]"
50
53
  rescue => ex
51
54
  puts "VMCATCHER UNKNOWN - #{ex.message}"
52
55
  puts ex.backtrace if options[:debug]
@@ -95,10 +98,14 @@ class Nagios::Promoo::Appdb::Probes::VmcatcherProbe < Nagios::Promoo::Appdb::Pro
95
98
  "from #{list_url.inspect} [#{response.code}]" unless response.success?
96
99
 
97
100
  list = JSON.parse OpenSSL::PKCS7.read_smime(response.parsed_response).data
98
- fail "AppDB image list #{list_url.inspect} does " \
99
- "not contain images" unless list && list['hv:imagelist'] && list['hv:imagelist']['hv:images']
101
+ fail "AppDB image list #{list_url.inspect} is empty or malformed" unless list && list['hv:imagelist']
102
+
103
+ list = list['hv:imagelist']
104
+ fail "AppDB image list #{list_url.inspect} has expired" unless DateTime.parse(list['dc:date:expires']) > Time.now
105
+ fail "AppDB image list #{list_url.inspect} doesn't contain images" unless list['hv:images']
100
106
 
101
- @_hv_images = list['hv:imagelist']['hv:images'].collect { |im| im['hv:image'] }.reject { |im| im.blank? || im['ad:mpuri'].blank? }
107
+ @_last_update = DateTime.parse list['dc:date:created']
108
+ @_hv_images = list['hv:images'].collect { |im| im['hv:image'] }.reject { |im| im.blank? || im['ad:mpuri'].blank? }
102
109
  end
103
110
 
104
111
  def normalize_mpuri(mpuri)
@@ -1,7 +1,7 @@
1
1
  module Nagios
2
2
  module Promoo
3
3
  module Appdb
4
- VERSION = "1.0.0"
4
+ VERSION = "1.1.0"
5
5
  end
6
6
  end
7
7
  end
@@ -1,5 +1,5 @@
1
1
  module Nagios
2
2
  module Promoo
3
- VERSION = "1.0.0"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
data/lib/nagios/promoo.rb CHANGED
@@ -1,9 +1,11 @@
1
1
  # Global deps
2
+ require 'active_support/all'
2
3
  require 'thor'
3
4
  require 'timeout'
4
5
  require 'ox'
5
6
  require 'multi_xml'
6
7
  require 'httparty'
8
+ require 'date'
7
9
 
8
10
  # Force multi_xml to use ox
9
11
  MultiXml.parser = :ox
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.0.0
4
+ version: 1.1.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-01-27 00:00:00.000000000 Z
11
+ date: 2017-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: occi-api