nagira 0.3.1 → 0.3.2

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: c09bc3962e430c97414b5e339bda189c34cb799a
4
- data.tar.gz: 7eb9575f51aa191a37ba1504b50e65d9a8e2882d
3
+ metadata.gz: f0d1159c3f0f60f42147bc66a3274f02b499087c
4
+ data.tar.gz: fa0384885a832cff96e1124ba14426799fbc34f7
5
5
  SHA512:
6
- metadata.gz: 3f7eb07bad39c7498eb7f3d07d6863124dbbf0baa66a4180ebcabebea252434d9c9fba91d4d7348bab223f97d0d442e7be27c77d7e50772d0cbb4ee9f45b9b42
7
- data.tar.gz: ece7da05d6591689494b15eea77da1a02dc0e9c1050f6064da5c8d34d33eaaefeccc868ff1617e5e66b1db332f2e4768a20e41379a8e8b216d3792056b5ebca3
6
+ metadata.gz: 3c8f272cd12b05e72fa09794ecc170b447a6ae2135d1d814f9ef2f71c7313a21386a85a25f11defad0c2fd2deff91458c5a285371edcf51e8bcf32f61a24dd3e
7
+ data.tar.gz: 90ba66335e2715eb62784600967a432bbf076246c6f715ff7d3cf524ee046d5f9f9265c67f6f52b26da6e8b158ebc540d5ef44385f69d41ea7d68bad3c7b0115
data/History.md CHANGED
@@ -1,4 +1,8 @@
1
1
  ### v.0.3.1
2
+ * Fri Aug 30 2013 -- Dmytro Kovalov
3
+ - Add requirement for Ruby version in gemspec
4
+ - Requirement documentation
5
+ ### v.0.3.1
2
6
  * Mon Aug 26 2013 -- Dmytro Kovalov
3
7
  - Bugfix: fix for init.d script to load defaults file
4
8
 
@@ -0,0 +1,98 @@
1
+ #
2
+ # Defaults configuration file for Nagira
3
+ # --------------------------------------------
4
+ <% %w{ NAGIRA_PORT NAGIRA_BIND RACK_ENV NAGIRA_USER RVM_STRING NAGIRA_LOG NAGIRA_TTL NAGIRA_BG_PARSING NAGIOS_CFG_FILE NAGIOS_HOST_CUSTOM_REGEX}.each do |env| -%>
5
+ <% if env.downcase.to_sym -%>
6
+ <%= env -%>=<%="#{env}" -%>
7
+ <% end -%>
8
+ <% end -%>
9
+ #
10
+ # Examples below are default values.
11
+ #
12
+ # ----------------------
13
+ # Port. Default 4567
14
+ # ----------------------
15
+ # NAGIRA_PORT=
16
+ #
17
+ # ----------------------
18
+ # BIND
19
+ # ----------------------
20
+ # String specifying the hostname or IP address of the interface to
21
+ # listen on when the :run setting is enabled. The default value –
22
+ # '0.0.0.0' – causes the server to listen on all available
23
+ # interfaces. To listen on the loopback interface only, use: 'localhost'
24
+ #
25
+ # NAGIRA_BIND=localhost
26
+ #
27
+ # ----------------------
28
+ # Environment
29
+ # ----------------------
30
+ # Usually needs to be production
31
+ #
32
+ # RACK_ENV=production
33
+ #
34
+ # ----------------------
35
+ # Nagira user
36
+ # ----------------------
37
+ # Usually nagira process should be run by same user ID as Nagios. In
38
+ # many cases this is nagios user.
39
+ #
40
+ # NAGIRA_USER=nagios
41
+ #
42
+ # ----------------------
43
+ # RVM
44
+ # ----------------------
45
+ # RVM_STRING="rvm use default"
46
+ #
47
+ # ----------------------
48
+ # Log file
49
+ # ----------------------
50
+ # NAGIRA_LOG=/var/log/nagios/nagira.log
51
+ #
52
+ # ----------------------
53
+ # TTL for data
54
+ # ----------------------
55
+ # Number of seconds between re-parses. All Nagios file are parsed no
56
+ # more often than this. Default is 5 sec. Setting this to 0 or
57
+ # negative number disables TTL and backgroiund prser as well.
58
+ #
59
+ # NAGIRA_TTL=20
60
+ #
61
+ # ----------------------
62
+ # Background parsing
63
+ # ----------------------
64
+ # Set this to 0, to disable background parsing.
65
+ # NAGIRA_BG_PARSING=1
66
+ #
67
+ # ----------------------
68
+ # Nagios configuration file
69
+ # ----------------------
70
+ # Where main Nagios configuration file is located. usually this does
71
+ # not need to change.
72
+ #
73
+ # NAGIOS_CFG_FILE=/etc/nagios/nagios.cfg
74
+ #
75
+ # ----------------------
76
+ # Custom regex for hostnames
77
+ # ----------------------
78
+ #
79
+ # By default hostname regular expression accepts alpha-numerics,
80
+ # dashes and dots, as specified by http://tools.ietf.org/html/rfc952
81
+ # for hostnames. Extended to accept dots in the middle for FQHN's.
82
+ #
83
+ # Possible settings:
84
+ #
85
+ # - default: '\w([\w\-\.]+)?\w' FQHN
86
+ # - short hostname: '\w([\w\-]+)?\w'
87
+ # - FQHN allow space in hostname: '\w([\w\-\.(%20)]+)?\w'
88
+ #
89
+ # Explanation regarding spaces:
90
+ # ---------------------------------
91
+ #
92
+ # Nagios works OK with hostnames with spaces. This is against RFC's
93
+ # and can't really used for real hosts, but for aggregated checks
94
+ # (like cluster name for example), you might want to consider this
95
+ # option.
96
+ #
97
+ # NAGIOS_HOST_CUSTOM_REGEX='\w([\w\-\.]+)?\w'
98
+ #
@@ -1,45 +1,4 @@
1
- require 'spec_helper'
2
-
3
- #
4
- # Specs for implemetned API endpoints. Only check response: OK or 404.
5
- #
6
-
7
- shared_examples_for :fail_on_random_url do |base|
8
- RANDOM.each do |url|
9
- ep = "#{base}/#{url}"
10
- it "fails on '#{ep}' string" do
11
- get ep
12
- last_response.status.should be 404
13
- end
14
- end
15
- end
16
-
17
- shared_examples_for :respond_to_valid_url do |base, urls, custom_regex|
18
-
19
- case urls
20
- when Array
21
- urls.each do |url|
22
- ep = "#{base}/#{url}"
23
- it "responds to #{ep}" do
24
- get ep
25
- last_response.should be_ok
26
- end
27
- end
28
- when nil
29
- ep = "#{base}"
30
- it "responds to #{ep}" do
31
- get ep
32
- last_response.should be_ok
33
- end
34
- end
35
- end
36
-
37
- shared_examples_for :fail_on_bad_url do |url|
38
- before { get url }
39
- it "fails on #{url}" do
40
- last_response.status.should be 404
41
- end
42
- end
1
+ require_relative 'get_helper'
43
2
 
44
3
  describe Nagira do
45
4
 
@@ -51,53 +10,9 @@ describe Nagira do
51
10
 
52
11
  context "API endpoints" do
53
12
 
54
- host = IMPLEMENTED[:hosts].first
55
- spaces = "host%20with%20space"
56
-
57
-
58
13
  context :top do
59
14
  it_should_behave_like :respond_to_valid_url, '', IMPLEMENTED[:top]
60
15
  it_should_behave_like :fail_on_random_url, ''
61
16
  end
62
-
63
-
64
- context "/_status" do
65
- it_should_behave_like :respond_to_valid_url, "/_status", IMPLEMENTED[:hosts]
66
- it_should_behave_like :respond_to_valid_url, "/_status", IMPLEMENTED[:output] + ["_hosts"]
67
- it_should_behave_like :fail_on_random_url, '/_status'
68
- end
69
-
70
- context "/_status/:host" do
71
- it_should_behave_like :respond_to_valid_url, "/_status/#{host}", IMPLEMENTED[:status]
72
- it_should_behave_like :fail_on_random_url, "/_status/#{host}"
73
-
74
- context "hostname with space" do
75
- it_should_behave_like :fail_on_bad_url, "/_status/#{spaces}"
76
- end
77
-
78
- context :unknown_host do
79
- it_should_behave_like :fail_on_bad_url, '/_status/unknown_host'
80
- it_should_behave_like :fail_on_random_url, "/_status/unknown_host"
81
- end
82
- end # /_status/:host
83
-
84
- context "/_status/:host/_services" do
85
- it_should_behave_like :respond_to_valid_url, "/_status/#{host}/_services"
86
- it_should_behave_like :respond_to_valid_url, "/_status/#{host}/_services", ["SSH", "PING"]
87
-
88
- context "hostname with space" do
89
- it_should_behave_like :fail_on_bad_url, "/_status/#{spaces}/_services"
90
- end
91
- end
92
-
93
-
94
- context "custom hostname regex - host with spaces" do
95
-
96
- it { pending "Need to figure out how to change hostname regex on the fly" }
97
- #it_should_behave_like :respond_to_valid_url, "/_status/#{spaces}", nil, '\w[(%20)\w\-\.]+'
98
- #it_should_behave_like :respond_to_valid_url, "/_status/#{spaces}/_services"
99
- end # custom hostname regex
100
-
101
- end # API endpoints
102
-
103
- end
17
+ end
18
+ end
@@ -0,0 +1,50 @@
1
+ require 'spec_helper'
2
+
3
+ IMPLEMENTED = {
4
+ top: %w{ _api _status _objects _config _runtime},
5
+ output: %w{ _list _state _full }, # Type of requests as in varaible @output
6
+ hosts: %w{ archive tv },
7
+ status: %w{ _services _servicecomments _hostcomments },
8
+ objects: %w{ timeperiod command contactgroup hostgroup contact host service }
9
+ }
10
+
11
+ #
12
+ # Specs for implemetned API endpoints. Only check response: OK or 404.
13
+ #
14
+
15
+ shared_examples_for :fail_on_random_url do |base|
16
+ RANDOM.each do |url|
17
+ ep = "#{base}/#{url}"
18
+ it "fails on '#{ep}' string" do
19
+ get ep
20
+ last_response.status.should be 404
21
+ end
22
+ end
23
+ end
24
+
25
+ shared_examples_for :respond_to_valid_url do |base, urls, custom_regex|
26
+
27
+ case urls
28
+ when Array
29
+ urls.each do |url|
30
+ ep = "#{base}/#{url}"
31
+ it "responds to #{ep}" do
32
+ get ep
33
+ last_response.should be_ok
34
+ end
35
+ end
36
+ when nil
37
+ ep = "#{base}"
38
+ it "responds to #{ep}" do
39
+ get ep
40
+ last_response.should be_ok
41
+ end
42
+ end
43
+ end
44
+
45
+ shared_examples_for :fail_on_bad_url do |url|
46
+ before { get url }
47
+ it "fails on #{url}" do
48
+ last_response.status.should be 404
49
+ end
50
+ end
@@ -0,0 +1,25 @@
1
+ require_relative '../get_helper'
2
+
3
+ describe Nagira do
4
+
5
+ set :environment, :test # This should run only in test mode as it uses hardcoded host names
6
+ include Rack::Test::Methods
7
+ def app
8
+ @app ||= Nagira
9
+ end
10
+
11
+ subject { JSON.parse last_response.body }
12
+
13
+ context "Data structure" do
14
+ context "/_objects" do
15
+
16
+ let (:host) { IMPLEMENTED[:hosts].first }
17
+
18
+ it { get "/_objects" ; should be_a_kind_of Hash }
19
+ it { get "/_objects/_list" ; should be_a_kind_of Array }
20
+ it { get "/_objects/host" ; should be_a_kind_of Hash }
21
+ it { get "/_objects/host/#{host}" ; should be_a_kind_of Hash }
22
+
23
+ end
24
+ end # Data structure
25
+ end # describe Nagira
@@ -0,0 +1,33 @@
1
+ require_relative '../get_helper'
2
+
3
+ describe Nagira do
4
+
5
+ set :environment, :test # This should run only in test mode as it uses hardcoded host names
6
+ include Rack::Test::Methods
7
+ def app
8
+ @app ||= Nagira
9
+ end
10
+
11
+ context "API endpoints" do
12
+ context "/_objects" do
13
+ it_should_behave_like :respond_to_valid_url, "/_objects"
14
+ it_should_behave_like :respond_to_valid_url, "/_objects/_list"
15
+
16
+
17
+ it_should_behave_like :respond_to_valid_url, "/_objects", IMPLEMENTED[:objects]
18
+ it_should_behave_like :fail_on_random_url, "/_objects"
19
+ # AR- compatibility
20
+ it_should_behave_like :respond_to_valid_url, "/_objects", IMPLEMENTED[:objects].map(&:pluralize)
21
+
22
+ context :host do
23
+ host = IMPLEMENTED[:hosts].first
24
+ spaces = "host%20with%20space"
25
+
26
+ it_should_behave_like :respond_to_valid_url, "/_objects/host/#{host}"
27
+ it_should_behave_like :fail_on_bad_url, "/_objects/host/#{spaces}"
28
+ it_should_behave_like :respond_to_valid_url, "/_objects/host/#{host}/_list"
29
+
30
+ end
31
+ end
32
+ end # API endpoints
33
+ end # describe Nagira
@@ -0,0 +1,103 @@
1
+ require 'spec_helper'
2
+
3
+ #
4
+ # Specs for implemetned API endpoints. Only check response: OK or 404.
5
+ #
6
+
7
+ shared_examples_for :fail_on_random_url do |base|
8
+ RANDOM.each do |url|
9
+ ep = "#{base}/#{url}"
10
+ it "fails on '#{ep}' string" do
11
+ get ep
12
+ last_response.status.should be 404
13
+ end
14
+ end
15
+ end
16
+
17
+ shared_examples_for :respond_to_valid_url do |base, urls, custom_regex|
18
+
19
+ case urls
20
+ when Array
21
+ urls.each do |url|
22
+ ep = "#{base}/#{url}"
23
+ it "responds to #{ep}" do
24
+ get ep
25
+ last_response.should be_ok
26
+ end
27
+ end
28
+ when nil
29
+ ep = "#{base}"
30
+ it "responds to #{ep}" do
31
+ get ep
32
+ last_response.should be_ok
33
+ end
34
+ end
35
+ end
36
+
37
+ shared_examples_for :fail_on_bad_url do |url|
38
+ before { get url }
39
+ it "fails on #{url}" do
40
+ last_response.status.should be 404
41
+ end
42
+ end
43
+
44
+ describe Nagira do
45
+
46
+ set :environment, :test # This should run only in test mode as it uses hardcoded host names
47
+ include Rack::Test::Methods
48
+ def app
49
+ @app ||= Nagira
50
+ end
51
+
52
+ context "API endpoints" do
53
+
54
+ host = IMPLEMENTED[:hosts].first
55
+ spaces = "host%20with%20space"
56
+
57
+
58
+ context :top do
59
+ it_should_behave_like :respond_to_valid_url, '', IMPLEMENTED[:top]
60
+ it_should_behave_like :fail_on_random_url, ''
61
+ end
62
+
63
+
64
+ context "/_status" do
65
+ it_should_behave_like :respond_to_valid_url, "/_status", IMPLEMENTED[:hosts]
66
+ it_should_behave_like :respond_to_valid_url, "/_status", IMPLEMENTED[:output] + ["_hosts"]
67
+ it_should_behave_like :fail_on_random_url, '/_status'
68
+ end
69
+
70
+ context "/_status/:host" do
71
+ it_should_behave_like :respond_to_valid_url, "/_status/#{host}", IMPLEMENTED[:status]
72
+ it_should_behave_like :fail_on_random_url, "/_status/#{host}"
73
+
74
+ context "hostname with space" do
75
+ it_should_behave_like :fail_on_bad_url, "/_status/#{spaces}"
76
+ end
77
+
78
+ context :unknown_host do
79
+ it_should_behave_like :fail_on_bad_url, '/_status/unknown_host'
80
+ it_should_behave_like :fail_on_random_url, "/_status/unknown_host"
81
+ end
82
+ end # /_status/:host
83
+
84
+ context "/_status/:host/_services" do
85
+ it_should_behave_like :respond_to_valid_url, "/_status/#{host}/_services"
86
+ it_should_behave_like :respond_to_valid_url, "/_status/#{host}/_services", ["SSH", "PING"]
87
+
88
+ context "hostname with space" do
89
+ it_should_behave_like :fail_on_bad_url, "/_status/#{spaces}/_services"
90
+ end
91
+ end
92
+
93
+
94
+ context "custom hostname regex - host with spaces" do
95
+
96
+ it { pending "Need to figure out how to change hostname regex on the fly" }
97
+ #it_should_behave_like :respond_to_valid_url, "/_status/#{spaces}", nil, '\w[(%20)\w\-\.]+'
98
+ #it_should_behave_like :respond_to_valid_url, "/_status/#{spaces}/_services"
99
+ end # custom hostname regex
100
+
101
+ end # API endpoints
102
+
103
+ end
@@ -1 +1 @@
1
- 0.3.1
1
+ 0.3.2
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nagira
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmytro Kovalov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-26 00:00:00.000000000 Z
11
+ date: 2013-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -303,8 +303,12 @@ files:
303
303
  - spec/01_data_format/03_api_spec.rb
304
304
  - spec/get/comments_spec.rb
305
305
  - spec/get/endpoints_spec.rb
306
+ - spec/get/get_helper.rb
306
307
  - spec/get/hosts_spec.rb
308
+ - spec/get/objects/data_spec.rb
309
+ - spec/get/objects/endpoints_spec.rb
307
310
  - spec/get/services_spec.rb
311
+ - spec/get/status/endpoints_spec.rb
308
312
  - spec/put/host_spec.rb
309
313
  - spec/put/status_spec.rb
310
314
  - spec/put/support.rb
@@ -312,6 +316,7 @@ files:
312
316
  - config/defaults.rb
313
317
  - config/environment.rb
314
318
  - config/nagira.defaults
319
+ - config/nagira.defaults.erb
315
320
  - config/nagira.init_d
316
321
  - test/benchmark.rb
317
322
  - test/data/bad/nagios.cfg
@@ -343,7 +348,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
343
348
  requirements:
344
349
  - - '>='
345
350
  - !ruby/object:Gem::Version
346
- version: '0'
351
+ version: 1.9.1
347
352
  required_rubygems_version: !ruby/object:Gem::Requirement
348
353
  requirements:
349
354
  - - '>='