nagios-promoo 1.1.0 → 1.2.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: 03a43d2f650bc5bfa06dc735193c61b22ec16fba
4
- data.tar.gz: f07fda7f6d2240c5e140509feeb05ab2b5c405d7
3
+ metadata.gz: a526ad530f8f724a31721b81e321ad2d6ba7d847
4
+ data.tar.gz: a8627259081ce7c0d5b928b826d5bab32a0af4c5
5
5
  SHA512:
6
- metadata.gz: 437c81a1847705426e476d597ed0e7744d463d3158c888db3b402340e374e1644ee74cc67c5782589f2719389e8fd950add0fa8ae2c3a28a73b9029e2b9fe8b4
7
- data.tar.gz: 36d059ca5a98c910f570b1ae6ca376f25e104fb618f817f2931ee4f01f5406d77def52f9671ca33cbea62db23357af1a950fb9a84d9b329c75c2ca9388388349
6
+ metadata.gz: 4b467c9e3a11f3f41c47f084c7a6f91efaf47a2f1b8c39995f1fe9dbd6056ab08e71eeb1ebded5f3747a9721c90233f06838d6337b72b121f793734ef5160439
7
+ data.tar.gz: 6c82cf8ac8d6a19ffaa9ae75eba459eb4e561cec0ef5547dea7a155d8d141e12699506d506cc1a9480e1c3c656cc8b069c4e931a9a54f3362a448d878b38aa3c
@@ -0,0 +1,10 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ Metrics/LineLength:
4
+ Max: 120
5
+
6
+ Metrics/BlockLength:
7
+ Exclude:
8
+ - 'spec/**/*'
9
+ - 'test/**/*'
10
+ - '*.gemspec'
@@ -0,0 +1,29 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2017-05-28 17:27:37 +0200 using RuboCop version 0.49.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 20
10
+ Metrics/AbcSize:
11
+ Max: 50
12
+
13
+ # Offense count: 3
14
+ # Configuration parameters: CountComments.
15
+ Metrics/ClassLength:
16
+ Max: 200
17
+
18
+ # Offense count: 5
19
+ Metrics/CyclomaticComplexity:
20
+ Max: 10
21
+
22
+ # Offense count: 20
23
+ # Configuration parameters: CountComments.
24
+ Metrics/MethodLength:
25
+ Max: 34
26
+
27
+ # Offense count: 3
28
+ Metrics/PerceivedComplexity:
29
+ Max: 10
@@ -0,0 +1,27 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 2.2.2
5
+ - 2.3.0
6
+ - 2.4.0
7
+ - ruby-head
8
+
9
+ matrix:
10
+ allow_failures:
11
+ - rvm: 2.3.0
12
+ - rvm: 2.4.0
13
+ - rvm: ruby-head
14
+ fast_finish: true
15
+
16
+ branches:
17
+ only:
18
+ - master
19
+
20
+ env:
21
+ - ON_TRAVIS_CI=yes
22
+
23
+ install: 'gem install bundler -v ">= 1.12" && bundle install --retry=10'
24
+
25
+ script: 'bundle exec rake rubocop && bundle exec bin/nagios-promoo version'
26
+
27
+ sudo: false
data/README.md CHANGED
@@ -1,16 +1,20 @@
1
- # Nagios Probes for Monitoring OpenNebula and OCCI-enabled clouds
1
+ # Nagios Probes for Monitoring OCA and OCCI
2
+ [![Travis](https://img.shields.io/travis/arax/nagios-promoo.svg?style=flat-square)](http://travis-ci.org/arax/nagios-promoo)
3
+ [![Gemnasium](https://img.shields.io/gemnasium/arax/nagios-promoo.svg?style=flat-square)](https://gemnasium.com/arax/nagios-promoo)
4
+ [![Gem](https://img.shields.io/gem/v/nagios-promoo.svg?style=flat-square)](https://rubygems.org/gems/nagios-promoo)
5
+ [![Code Climate](https://img.shields.io/codeclimate/github/arax/nagios-promoo.svg?style=flat-square)](https://codeclimate.com/github/arax/nagios-promoo)
2
6
 
3
7
  ## Installation
4
8
 
5
- $ gem install nagios-promoo
9
+ $ gem install nagios-promoo
6
10
 
7
11
  ## Usage
8
12
 
9
- $ nagios-promoo help
13
+ $ nagios-promoo help
10
14
 
11
15
  ## Contributing
12
16
 
13
- 1. Fork it ( https://github.com/EGI-FCTF/nagios-promoo/fork )
17
+ 1. Fork it ( https://github.com/arax/nagios-promoo/fork )
14
18
  2. Create your feature branch (`git checkout -b my-new-feature`)
15
19
  3. Commit your changes (`git commit -am 'Add some feature'`)
16
20
  4. Push to the branch (`git push origin my-new-feature`)
data/Rakefile CHANGED
@@ -1,2 +1,7 @@
1
- require "bundler/gem_tasks"
1
+ require 'rubygems/tasks'
2
+ require 'rubocop/rake_task'
2
3
 
4
+ Gem::Tasks.new(build: { tar: true, zip: true }, sign: { checksum: true, pgp: false })
5
+ RuboCop::RakeTask.new
6
+
7
+ task default: 'rubocop'
@@ -10,11 +10,17 @@ require 'date'
10
10
  # Force multi_xml to use ox
11
11
  MultiXml.parser = :ox
12
12
 
13
- # Define modules
14
- module Nagios; end
15
- module Nagios::Promoo; end
13
+ # Gem namespace module.
14
+ #
15
+ # @author Boris Parak <parak@cesnet.cz>
16
+ module Nagios
17
+ # Namespace for `promoo` classes and modules.
18
+ #
19
+ # @author Boris Parak <parak@cesnet.cz>
20
+ module Promoo; end
21
+ end
16
22
 
17
23
  # Include necessary files
18
- require "nagios/promoo/version"
19
- require "nagios/promoo/utils"
20
- require "nagios/promoo/master"
24
+ require 'nagios/promoo/version'
25
+ require 'nagios/promoo/utils'
26
+ require 'nagios/promoo/master'
@@ -1,40 +1,67 @@
1
1
  # Internal deps
2
2
  require File.join(File.dirname(__FILE__), 'version')
3
3
 
4
- # Define modules
5
- module Nagios::Promoo::Appdb; end
6
- module Nagios::Promoo::Appdb::Probes; end
4
+ module Nagios
5
+ module Promoo
6
+ # Namespace for AppDB-related code.
7
+ #
8
+ # @author Boris Parak <parak@cesnet.cz>
9
+ module Appdb
10
+ # Namespace for probes checking AppDB.
11
+ #
12
+ # @author Boris Parak <parak@cesnet.cz>
13
+ module Probes; end
14
+ end
15
+ end
16
+ end
17
+
7
18
  Dir.glob(File.join(File.dirname(__FILE__), 'probes', '*.rb')) { |probe| require probe.chomp('.rb') }
8
19
 
9
- class Nagios::Promoo::Appdb::Master < ::Thor
10
- class << self
11
- # Hack to override the help message produced by Thor.
12
- # https://github.com/wycats/thor/issues/261#issuecomment-16880836
13
- def banner(command, namespace = nil, subcommand = nil)
14
- "#{basename} appdb #{command.usage}"
15
- end
20
+ module Nagios
21
+ module Promoo
22
+ module Appdb
23
+ # Master class for all AppDB probes.
24
+ #
25
+ # @author Boris Parak <parak@cesnet.cz>
26
+ class Master < ::Thor
27
+ class << self
28
+ # Hack to override the help message produced by Thor.
29
+ # https://github.com/wycats/thor/issues/261#issuecomment-16880836
30
+ def banner(command, _namespace = nil, _subcommand = nil)
31
+ "#{basename} appdb #{command.usage}"
32
+ end
16
33
 
17
- def available_probes
18
- Nagios::Promoo::Appdb::Probes.constants.collect { |probe| Nagios::Promoo::Appdb::Probes.const_get(probe) }.reject { |probe| !probe.runnable? }
19
- end
20
- end
34
+ def available_probes
35
+ probes = Nagios::Promoo::Appdb::Probes.constants.collect do |probe|
36
+ Nagios::Promoo::Appdb::Probes.const_get(probe)
37
+ end
38
+ probes.select(&:runnable?)
39
+ end
40
+ end
21
41
 
22
- class_option :endpoint, type: :string, desc: 'Site\'s OCCI endpoint, as specified in GOCDB', default: 'http://localhost:3000/'
42
+ class_option :endpoint,
43
+ type: :string,
44
+ desc: 'Site\'s OCCI endpoint, as specified in GOCDB',
45
+ default: 'http://localhost:3000/'
23
46
 
24
- available_probes.each do |probe|
25
- desc *probe.description
26
- probe.options.each do |opt|
27
- option opt.first, opt.last
28
- end
29
- class_eval %Q^
47
+ available_probes.each do |probe|
48
+ desc(*probe.description)
49
+ probe.options.each do |opt|
50
+ option opt.first, opt.last
51
+ end
52
+
53
+ class_eval %^
30
54
  def #{probe.declaration}(*args)
31
55
  #{probe}.new(options).run(args)
32
56
  end
33
57
  ^
34
- end
58
+ end
35
59
 
36
- desc 'version', 'Print version of the AppDB probe set'
37
- def version
38
- puts Nagios::Promoo::Appdb::VERSION
60
+ desc 'version', 'Print version of the AppDB probe set'
61
+ def version
62
+ puts Nagios::Promoo::Appdb::VERSION
63
+ end
64
+ end
65
+ end
39
66
  end
40
67
  end
@@ -1,43 +1,56 @@
1
1
  # Internal deps
2
2
  require File.join(File.dirname(__FILE__), 'base_probe')
3
3
 
4
- class Nagios::Promoo::Appdb::Probes::AppliancesProbe < Nagios::Promoo::Appdb::Probes::BaseProbe
5
- class << self
6
- def description
7
- ['appliances', 'Run a probe checking appliances in AppDB']
4
+ module Nagios
5
+ module Promoo
6
+ module Appdb
7
+ module Probes
8
+ # Probe for checking appliance availability in AppDB.
9
+ #
10
+ # @author Boris Parak <parak@cesnet.cz>
11
+ class AppliancesProbe < Nagios::Promoo::Appdb::Probes::BaseProbe
12
+ class << self
13
+ def description
14
+ ['appliances', 'Run a probe checking appliances in AppDB']
15
+ end
16
+
17
+ def options
18
+ []
19
+ end
20
+
21
+ def declaration
22
+ 'appliances'
23
+ end
24
+
25
+ def runnable?
26
+ true
27
+ end
28
+ end
29
+
30
+ def run(_args = [])
31
+ @_count = 0
32
+
33
+ Timeout.timeout(options[:timeout]) { check_appliances }
34
+
35
+ if @_count < 1
36
+ puts 'APPLIANCES CRITICAL - No appliances found in AppDB'
37
+ exit 2
38
+ end
39
+
40
+ puts "APPLIANCES OK - Found #{@_count} appliances in AppDB"
41
+ rescue => ex
42
+ puts "APPLIANCES UNKNOWN - #{ex.message}"
43
+ puts ex.backtrace if options[:debug]
44
+ exit 3
45
+ end
46
+
47
+ private
48
+
49
+ def check_appliances
50
+ @_count = [appdb_provider['provider:image']].flatten.compact.count
51
+ end
52
+ end
53
+ end
8
54
  end
9
-
10
- def options
11
- []
12
- end
13
-
14
- def declaration
15
- "appliances"
16
- end
17
-
18
- def runnable?; true; end
19
- end
20
-
21
- def run(args = [])
22
- @_count = 0
23
-
24
- Timeout::timeout(options[:timeout]) { check_appliances }
25
-
26
- if @_count < 1
27
- puts "APPLIANCES CRITICAL - No appliances found in AppDB"
28
- exit 2
29
- end
30
-
31
- puts "APPLIANCES OK - Found #{@_count} appliances in AppDB"
32
- rescue => ex
33
- puts "APPLIANCES UNKNOWN - #{ex.message}"
34
- puts ex.backtrace if options[:debug]
35
- exit 3
36
- end
37
-
38
- private
39
-
40
- def check_appliances
41
- @_count = [appdb_provider['provider:image']].flatten.compact.count
42
55
  end
43
56
  end
@@ -1,42 +1,62 @@
1
- class Nagios::Promoo::Appdb::Probes::BaseProbe
2
- class << self
3
- def runnable?; false; end
4
- end
5
-
6
- APPDB_PROXY_URL = 'https://appdb.egi.eu/api/proxy'
7
- APPDB_REQUEST_FORM = 'version=1.0&resource=broker&data=%3Cappdb%3Abroker%20xmlns%3Axs%3D%22http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema%22%20xmlns%3Axsi%3D%22http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema-instance%22%20xmlns%3Aappdb%3D%22http%3A%2F%2Fappdb.egi.eu%2Fapi%2F1.0%2Fappdb%22%3E%3Cappdb%3Arequest%20id%3D%22vaproviders%22%20method%3D%22GET%22%20resource%3D%22va_providers%22%3E%3Cappdb%3Aparam%20name%3D%22listmode%22%3Edetails%3C%2Fappdb%3Aparam%3E%3C%2Fappdb%3Arequest%3E%3C%2Fappdb%3Abroker%3E'
8
-
9
- attr_reader :options
10
-
11
- def initialize(options)
12
- @options = options
13
- end
14
-
15
- def appdb_provider
16
- return @_provider if @_provider
17
-
18
- response = HTTParty.post(APPDB_PROXY_URL, { :body => APPDB_REQUEST_FORM })
19
- fail "Could not get site"\
20
- "details from AppDB [HTTP #{response.code}]" unless response.success?
21
- fail "Response from AppDB has unexpected structure" unless valid_response?(response.parsed_response)
22
-
23
- providers = response.parsed_response['appdb:broker']['appdb:reply']['appdb:appdb']['virtualization:provider']
24
- providers.delete_if { |prov| prov['provider:endpoint_url'].blank? }
25
-
26
- @_provider = providers.select do |prov|
27
- prov['provider:endpoint_url'].chomp('/') == options[:endpoint].chomp('/')
28
- end.first
29
- fail "Could not locate site by endpoint #{options[:endpoint].inspect} in AppDB" unless @_provider
30
-
31
- @_provider
32
- end
33
-
34
- private
35
-
36
- def valid_response?(response)
37
- response['appdb:broker'] \
38
- && response['appdb:broker']['appdb:reply'] \
39
- && response['appdb:broker']['appdb:reply']['appdb:appdb'] \
40
- && response['appdb:broker']['appdb:reply']['appdb:appdb']['virtualization:provider']
1
+ module Nagios
2
+ module Promoo
3
+ module Appdb
4
+ module Probes
5
+ # Base probe class for all AppDB-related probes.
6
+ #
7
+ # @author Boris Parak <parak@cesnet.cz>
8
+ class BaseProbe
9
+ class << self
10
+ def runnable?
11
+ false
12
+ end
13
+ end
14
+
15
+ APPDB_PROXY_URL = 'https://appdb.egi.eu/api/proxy'.freeze
16
+ APPDB_REQUEST_FORM = 'version=1.0&resource=broker&data=%3Cappdb%3Abroker%20xmlns%3Axs%3D%22http%3A%2F%2F' \
17
+ 'www.w3.org%2F2001%2FXMLSchema%22%20xmlns%3Axsi%3D%22http%3A%2F%2Fwww.w3.org%2F2001%2F' \
18
+ 'XMLSchema-instance%22%20xmlns%3Aappdb%3D%22http%3A%2F%2Fappdb.egi.eu%2Fapi%2F1.0%2F' \
19
+ 'appdb%22%3E%3Cappdb%3Arequest%20id%3D%22vaproviders%22%20method%3D%22GET%22%20' \
20
+ 'resource%3D%22va_providers%22%3E%3Cappdb%3Aparam%20name%3D%22listmode%22%3Edetails' \
21
+ '%3C%2Fappdb%3Aparam%3E%3C%2Fappdb%3Arequest%3E%3C%2Fappdb%3Abroker%3E'.freeze
22
+
23
+ attr_reader :options
24
+
25
+ def initialize(options)
26
+ @options = options
27
+ end
28
+
29
+ def appdb_provider
30
+ return @_provider if @_provider
31
+
32
+ @_provider = appdb_providers.detect do |prov|
33
+ prov['provider:endpoint_url'].chomp('/') == options[:endpoint].chomp('/')
34
+ end
35
+ raise "Could not locate site by endpoint #{options[:endpoint].inspect} in AppDB" unless @_provider
36
+
37
+ @_provider
38
+ end
39
+
40
+ private
41
+
42
+ def appdb_providers
43
+ response = HTTParty.post(APPDB_PROXY_URL, body: APPDB_REQUEST_FORM)
44
+ raise "Could not get site details from AppDB [HTTP #{response.code}]" unless response.success?
45
+ raise 'Response from AppDB has unexpected structure' unless valid_response?(response.parsed_response)
46
+
47
+ providers = response.parsed_response['appdb:broker']['appdb:reply']\
48
+ ['appdb:appdb']['virtualization:provider']
49
+ providers.delete_if { |prov| prov['provider:endpoint_url'].blank? }
50
+ end
51
+
52
+ def valid_response?(response)
53
+ response['appdb:broker'] \
54
+ && response['appdb:broker']['appdb:reply'] \
55
+ && response['appdb:broker']['appdb:reply']['appdb:appdb'] \
56
+ && response['appdb:broker']['appdb:reply']['appdb:appdb']['virtualization:provider']
57
+ end
58
+ end
59
+ end
60
+ end
41
61
  end
42
62
  end
@@ -1,43 +1,56 @@
1
1
  # Internal deps
2
2
  require File.join(File.dirname(__FILE__), 'base_probe')
3
3
 
4
- class Nagios::Promoo::Appdb::Probes::SizesProbe < Nagios::Promoo::Appdb::Probes::BaseProbe
5
- class << self
6
- def description
7
- ['sizes', 'Run a probe checking size/flavor/resource templates in AppDB']
4
+ module Nagios
5
+ module Promoo
6
+ module Appdb
7
+ module Probes
8
+ # Probe for checking flavors/sizes in AppDB.
9
+ #
10
+ # @author Boris Parak <parak@cesnet.cz>
11
+ class SizesProbe < Nagios::Promoo::Appdb::Probes::BaseProbe
12
+ class << self
13
+ def description
14
+ ['sizes', 'Run a probe checking size/flavor/resource templates in AppDB']
15
+ end
16
+
17
+ def options
18
+ []
19
+ end
20
+
21
+ def declaration
22
+ 'sizes'
23
+ end
24
+
25
+ def runnable?
26
+ true
27
+ end
28
+ end
29
+
30
+ def run(_args = [])
31
+ @_count = 0
32
+
33
+ Timeout.timeout(options[:timeout]) { check_sizes }
34
+
35
+ if @_count < 1
36
+ puts 'SIZES CRITICAL - No size/flavor/resource templates found in AppDB'
37
+ exit 2
38
+ end
39
+
40
+ puts "SIZES OK - Found #{@_count} size/flavor/resource templates in AppDB"
41
+ rescue => ex
42
+ puts "SIZES UNKNOWN - #{ex.message}"
43
+ puts ex.backtrace if options[:debug]
44
+ exit 3
45
+ end
46
+
47
+ private
48
+
49
+ def check_sizes
50
+ @_count = [appdb_provider['provider:template']].flatten.compact.count
51
+ end
52
+ end
53
+ end
8
54
  end
9
-
10
- def options
11
- []
12
- end
13
-
14
- def declaration
15
- "sizes"
16
- end
17
-
18
- def runnable?; true; end
19
- end
20
-
21
- def run(args = [])
22
- @_count = 0
23
-
24
- Timeout::timeout(options[:timeout]) { check_sizes }
25
-
26
- if @_count < 1
27
- puts "SIZES CRITICAL - No size/flavor/resource templates found in AppDB"
28
- exit 2
29
- end
30
-
31
- puts "SIZES OK - Found #{@_count} size/flavor/resource templates in AppDB"
32
- rescue => ex
33
- puts "SIZES UNKNOWN - #{ex.message}"
34
- puts ex.backtrace if options[:debug]
35
- exit 3
36
- end
37
-
38
- private
39
-
40
- def check_sizes
41
- @_count = [appdb_provider['provider:template']].flatten.compact.count
42
55
  end
43
56
  end