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 +4 -4
- data/.rubocop.yml +10 -0
- data/.rubocop_todo.yml +29 -0
- data/.travis.yml +27 -0
- data/README.md +8 -4
- data/Rakefile +6 -1
- data/lib/nagios/promoo.rb +12 -6
- data/lib/nagios/promoo/appdb/master.rb +52 -25
- data/lib/nagios/promoo/appdb/probes/appliances_probe.rb +50 -37
- data/lib/nagios/promoo/appdb/probes/base_probe.rb +60 -40
- data/lib/nagios/promoo/appdb/probes/sizes_probe.rb +50 -37
- data/lib/nagios/promoo/appdb/probes/sync_probe.rb +179 -0
- data/lib/nagios/promoo/appdb/version.rb +1 -1
- data/lib/nagios/promoo/master.rb +37 -19
- data/lib/nagios/promoo/occi/master.rb +58 -27
- data/lib/nagios/promoo/occi/probes/base_probe.rb +37 -24
- data/lib/nagios/promoo/occi/probes/categories_probe.rb +88 -46
- data/lib/nagios/promoo/occi/probes/compute_probe.rb +249 -202
- data/lib/nagios/promoo/occi/probes/kinds_probe.rb +83 -52
- data/lib/nagios/promoo/occi/probes/mixins_probe.rb +62 -37
- data/lib/nagios/promoo/occi/version.rb +1 -1
- data/lib/nagios/promoo/opennebula/master.rb +55 -26
- data/lib/nagios/promoo/opennebula/probes/base_probe.rb +35 -12
- data/lib/nagios/promoo/opennebula/probes/virtual_machine_probe.rb +138 -100
- data/lib/nagios/promoo/opennebula/probes/xmlrpc_health_probe.rb +34 -21
- data/lib/nagios/promoo/opennebula/version.rb +1 -1
- data/lib/nagios/promoo/utils.rb +47 -25
- data/lib/nagios/promoo/version.rb +1 -1
- data/nagios-promoo.gemspec +5 -4
- metadata +9 -6
- data/lib/nagios/promoo/appdb/probes/vmcatcher_probe.rb +0 -118
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a526ad530f8f724a31721b81e321ad2d6ba7d847
|
4
|
+
data.tar.gz: a8627259081ce7c0d5b928b826d5bab32a0af4c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b467c9e3a11f3f41c47f084c7a6f91efaf47a2f1b8c39995f1fe9dbd6056ab08e71eeb1ebded5f3747a9721c90233f06838d6337b72b121f793734ef5160439
|
7
|
+
data.tar.gz: 6c82cf8ac8d6a19ffaa9ae75eba459eb4e561cec0ef5547dea7a155d8d141e12699506d506cc1a9480e1c3c656cc8b069c4e931a9a54f3362a448d878b38aa3c
|
data/.rubocop.yml
ADDED
data/.rubocop_todo.yml
ADDED
@@ -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
|
data/.travis.yml
ADDED
@@ -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
|
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
|
-
|
9
|
+
$ gem install nagios-promoo
|
6
10
|
|
7
11
|
## Usage
|
8
12
|
|
9
|
-
|
13
|
+
$ nagios-promoo help
|
10
14
|
|
11
15
|
## Contributing
|
12
16
|
|
13
|
-
1. Fork it ( https://github.com/
|
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
data/lib/nagios/promoo.rb
CHANGED
@@ -10,11 +10,17 @@ require 'date'
|
|
10
10
|
# Force multi_xml to use ox
|
11
11
|
MultiXml.parser = :ox
|
12
12
|
|
13
|
-
#
|
14
|
-
|
15
|
-
|
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
|
19
|
-
require
|
20
|
-
require
|
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
|
-
|
5
|
-
module
|
6
|
-
|
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
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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
|
-
|
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
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
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
|
-
|
58
|
+
end
|
35
59
|
|
36
|
-
|
37
|
-
|
38
|
-
|
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
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
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
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
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
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
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
|