nagira 0.3.3 → 0.4.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 +29 -23
- data/{lib → app}/app.rb +6 -7
- data/{lib/app/routes → app}/get/config.rb +0 -0
- data/{lib/app/routes → app}/get/objects.rb +0 -0
- data/{lib/app/routes → app}/get/status.rb +18 -15
- data/app/get/status/hostgroups.rb +49 -0
- data/{lib/app/routes → app}/put.rb +0 -0
- data/{lib/app/routes → app}/put/host.rb +0 -0
- data/{lib/app/routes → app}/put/status.rb +0 -0
- data/bin/nagira +3 -3
- data/config/defaults.rb +9 -10
- data/config/environment.rb +9 -10
- data/lib/nagira.rb +12 -8
- data/lib/nagira/hostgroup.rb +46 -0
- data/spec/00_configuration_spec.rb +21 -21
- data/spec/01_data_format/01_nagira_response_spec.rb +26 -26
- data/spec/01_data_format/02_0_status_spec.rb +11 -11
- data/spec/01_data_format/02_nagira_data_spec.rb +27 -27
- data/spec/01_data_format/03_api_spec.rb +12 -12
- data/spec/get/comments_spec.rb +15 -15
- data/spec/get/endpoints_spec.rb +34 -19
- data/spec/get/hostgroup.rb +79 -0
- data/spec/get/hosts_spec.rb +10 -10
- data/spec/get/services_spec.rb +8 -8
- data/spec/put/host_spec.rb +12 -12
- data/spec/put/status_spec.rb +23 -22
- data/spec/put/support.rb +24 -24
- data/spec/spec_helper.rb +3 -2
- data/version.txt +1 -1
- metadata +45 -27
data/spec/put/status_spec.rb
CHANGED
@@ -42,66 +42,67 @@ describe Nagira do
|
|
42
42
|
#
|
43
43
|
|
44
44
|
context "/_status/:host/_services" do
|
45
|
-
|
46
|
-
context :single do
|
47
|
-
|
45
|
+
|
46
|
+
context :single do
|
47
|
+
|
48
48
|
let (:url) { "/_status/#{host}/_services" }
|
49
49
|
before (:each) do
|
50
50
|
put url, @input.to_json, content_type
|
51
51
|
end
|
52
|
-
|
52
|
+
|
53
53
|
it_should_behave_like :put_status
|
54
|
-
|
54
|
+
|
55
55
|
it "URL param hostname is higher priority than JSON" do
|
56
56
|
pending
|
57
|
+
fail
|
57
58
|
# put url, @input.merge({ "host_name" => "fake_host"}).to_json, content_type
|
58
59
|
|
59
|
-
# out = JSON.parse last_response.body
|
60
|
+
# out = JSON.parse last_response.body
|
60
61
|
# pp out
|
61
62
|
# out["object"]["data"]["host_name"].should eq host
|
62
63
|
end
|
63
|
-
|
64
|
+
|
64
65
|
it "update with valid data" do
|
65
|
-
last_response.
|
66
|
+
expect(last_response).to be_ok
|
66
67
|
end
|
67
|
-
|
68
|
+
|
68
69
|
it 'Fails with missing data' do
|
69
70
|
@input.keys.each do |key|
|
70
71
|
data = @input.dup
|
71
72
|
data.delete key
|
72
73
|
put url, data.to_json, content_type
|
73
|
-
last_response.status.
|
74
|
+
expect(last_response.status).to eq 400
|
74
75
|
end
|
75
76
|
end
|
76
77
|
end
|
77
|
-
|
78
|
+
|
78
79
|
context :multiple do
|
79
80
|
let (:url) { "/_status/#{host}/_services" }
|
80
81
|
before do
|
81
82
|
put url, [@input, @input2].to_json, content_type
|
82
83
|
end
|
83
|
-
|
84
|
+
|
84
85
|
let (:out) { JSON.parse last_response.body }
|
85
|
-
|
86
|
+
|
86
87
|
it_should_behave_like :put_status
|
87
|
-
|
88
|
-
context "data check" do
|
88
|
+
|
89
|
+
context "data check" do
|
89
90
|
subject { out["object"] }
|
90
|
-
|
91
|
-
it {
|
92
|
-
it { subject.size.
|
91
|
+
|
92
|
+
it { expect(subject).to be_a_kind_of Array }
|
93
|
+
it { expect(subject.size).to eq 2 }
|
93
94
|
end
|
94
95
|
end
|
95
96
|
end
|
96
|
-
|
97
|
+
|
97
98
|
context "/_status/:host_name/_services/:service_description" do
|
98
99
|
let(:url) { "/_status/#{host}/_services/PING" }
|
99
100
|
before do
|
100
101
|
put url, [{ return_code: 0, plugin_output: "All OK"}].to_json, content_type
|
101
102
|
end
|
102
|
-
|
103
|
+
|
103
104
|
it "writes status" do
|
104
|
-
last_response.
|
105
|
+
expect(last_response).to be_ok
|
105
106
|
end
|
106
107
|
it_should_behave_like :put_status
|
107
108
|
|
@@ -125,7 +126,7 @@ describe Nagira do
|
|
125
126
|
|
126
127
|
|
127
128
|
context "/_status/:host_name/_services/:service_description/_return_code/:return_code/_plugin_output/:plugin_output" do
|
128
|
-
it { pending "To be depreciated "}
|
129
|
+
it { pending "To be depreciated "; fail}
|
129
130
|
end
|
130
131
|
|
131
132
|
end # update /_hosts
|
data/spec/put/support.rb
CHANGED
@@ -1,31 +1,31 @@
|
|
1
|
-
shared_examples_for :json_response do
|
2
|
-
before (:each) do
|
1
|
+
shared_examples_for :json_response do
|
2
|
+
before (:each) do
|
3
3
|
@ret = JSON.parse(last_response.body)
|
4
4
|
end
|
5
5
|
subject { @ret }
|
6
|
-
|
7
|
-
it {
|
8
|
-
it {
|
9
|
-
it {
|
6
|
+
|
7
|
+
it { expect(subject).to be_a_kind_of Hash }
|
8
|
+
it { expect(subject).to have_key "result" }
|
9
|
+
it { expect(subject).to have_key "object" }
|
10
10
|
|
11
11
|
let (:obj) { subject["object"] }
|
12
12
|
|
13
13
|
context :object do
|
14
14
|
# subject { obj }
|
15
|
-
|
16
|
-
it { obj.
|
17
|
-
it {
|
18
|
-
obj.each { |x| x.
|
15
|
+
|
16
|
+
it { expect(obj).to be_a_kind_of Array }
|
17
|
+
it {
|
18
|
+
obj.each { |x| expect(x).to be_a_kind_of Hash }
|
19
19
|
}
|
20
20
|
|
21
21
|
context :data_keys do
|
22
|
-
|
22
|
+
|
23
23
|
it do
|
24
|
-
obj.each do |x|
|
25
|
-
x.
|
26
|
-
x.
|
27
|
-
x.
|
28
|
-
[true, false].
|
24
|
+
obj.each do |x|
|
25
|
+
expect(x).to have_key "data"
|
26
|
+
expect(x).to have_key "result"
|
27
|
+
expect(x).to have_key "messages"
|
28
|
+
expect([true, false]).to include x["result"]
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
@@ -33,31 +33,31 @@ shared_examples_for :json_response do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
shared_examples_for :json_success_response do
|
36
|
-
before (:each) do
|
36
|
+
before (:each) do
|
37
37
|
@ret = JSON.parse(last_response.body)
|
38
38
|
end
|
39
39
|
subject { @ret }
|
40
|
-
|
40
|
+
|
41
41
|
end
|
42
42
|
|
43
43
|
shared_examples_for :write_to_nagios_cmd_file do
|
44
|
-
before (:all) do
|
44
|
+
before (:all) do
|
45
45
|
File.delete $nagios[:commands].path rescue nil
|
46
46
|
end
|
47
47
|
let (:cmd) { $nagios[:commands].path }
|
48
|
-
|
48
|
+
|
49
49
|
it "writes to nagios.cmd file" do
|
50
|
-
File.
|
51
|
-
File.read(cmd).
|
50
|
+
expect(File).to exist(cmd)
|
51
|
+
expect(File.read(cmd)).to match(/^\[\d+\] PROCESS_(SERVICE|HOST)_CHECK_RESULT;#{host}/)
|
52
52
|
end
|
53
53
|
|
54
|
-
after (:each) do
|
54
|
+
after (:each) do
|
55
55
|
File.delete $nagios[:commands].path rescue nil
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
59
|
|
60
|
-
shared_examples_for :put_status do
|
60
|
+
shared_examples_for :put_status do
|
61
61
|
it_should_behave_like :json_response
|
62
62
|
it_should_behave_like :write_to_nagios_cmd_file
|
63
63
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
$: << File.dirname(__FILE__) + '/../lib/'
|
2
2
|
require_relative '../lib/nagira.rb'
|
3
|
-
require_relative '../
|
3
|
+
require_relative '../app/app.rb'
|
4
4
|
require 'rack/test'
|
5
5
|
|
6
6
|
IMPLEMENTED = {
|
7
7
|
top: %w{ _api _status _objects _config _runtime},
|
8
8
|
output: %w{ _list _state _full }, # Type of requests as in varaible @output
|
9
9
|
hosts: %w{ archive tv },
|
10
|
-
|
10
|
+
hostgoups: %w{ all linux },
|
11
|
+
status: %w{ _services _servicecomments _hostcomments}
|
11
12
|
}
|
12
13
|
|
13
14
|
RANDOM = %w{ _bla _foo bla foo ahdhjdjda }
|
data/version.txt
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.0
|
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.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmytro Kovalov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -56,16 +56,16 @@ dependencies:
|
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 3.1.x
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 3.1.x
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: sherlock_os
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -90,44 +90,44 @@ dependencies:
|
|
90
90
|
name: rspec-core
|
91
91
|
requirement: !ruby/object:Gem::Requirement
|
92
92
|
requirements:
|
93
|
-
- -
|
93
|
+
- - ~>
|
94
94
|
- !ruby/object:Gem::Version
|
95
|
-
version:
|
95
|
+
version: 3.1.x
|
96
96
|
type: :runtime
|
97
97
|
prerelease: false
|
98
98
|
version_requirements: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
|
-
- -
|
100
|
+
- - ~>
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version:
|
102
|
+
version: 3.1.x
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
104
|
name: rspec-expectations
|
105
105
|
requirement: !ruby/object:Gem::Requirement
|
106
106
|
requirements:
|
107
|
-
- -
|
107
|
+
- - ~>
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version:
|
109
|
+
version: 3.1.x
|
110
110
|
type: :runtime
|
111
111
|
prerelease: false
|
112
112
|
version_requirements: !ruby/object:Gem::Requirement
|
113
113
|
requirements:
|
114
|
-
- -
|
114
|
+
- - ~>
|
115
115
|
- !ruby/object:Gem::Version
|
116
|
-
version:
|
116
|
+
version: 3.1.x
|
117
117
|
- !ruby/object:Gem::Dependency
|
118
118
|
name: rspec-mocks
|
119
119
|
requirement: !ruby/object:Gem::Requirement
|
120
120
|
requirements:
|
121
|
-
- -
|
121
|
+
- - ~>
|
122
122
|
- !ruby/object:Gem::Version
|
123
|
-
version:
|
123
|
+
version: 3.1.x
|
124
124
|
type: :runtime
|
125
125
|
prerelease: false
|
126
126
|
version_requirements: !ruby/object:Gem::Requirement
|
127
127
|
requirements:
|
128
|
-
- -
|
128
|
+
- - ~>
|
129
129
|
- !ruby/object:Gem::Version
|
130
|
-
version:
|
130
|
+
version: 3.1.x
|
131
131
|
- !ruby/object:Gem::Dependency
|
132
132
|
name: ruby-nagios
|
133
133
|
requirement: !ruby/object:Gem::Requirement
|
@@ -204,6 +204,20 @@ dependencies:
|
|
204
204
|
- - ~>
|
205
205
|
- !ruby/object:Gem::Version
|
206
206
|
version: 1.0.3
|
207
|
+
- !ruby/object:Gem::Dependency
|
208
|
+
name: pry
|
209
|
+
requirement: !ruby/object:Gem::Requirement
|
210
|
+
requirements:
|
211
|
+
- - ~>
|
212
|
+
- !ruby/object:Gem::Version
|
213
|
+
version: 0.10.x
|
214
|
+
type: :development
|
215
|
+
prerelease: false
|
216
|
+
version_requirements: !ruby/object:Gem::Requirement
|
217
|
+
requirements:
|
218
|
+
- - ~>
|
219
|
+
- !ruby/object:Gem::Version
|
220
|
+
version: 0.10.x
|
207
221
|
- !ruby/object:Gem::Dependency
|
208
222
|
name: guard-brakeman
|
209
223
|
requirement: !ruby/object:Gem::Requirement
|
@@ -224,14 +238,14 @@ dependencies:
|
|
224
238
|
requirements:
|
225
239
|
- - ~>
|
226
240
|
- !ruby/object:Gem::Version
|
227
|
-
version:
|
241
|
+
version: 4.x.x
|
228
242
|
type: :development
|
229
243
|
prerelease: false
|
230
244
|
version_requirements: !ruby/object:Gem::Requirement
|
231
245
|
requirements:
|
232
246
|
- - ~>
|
233
247
|
- !ruby/object:Gem::Version
|
234
|
-
version:
|
248
|
+
version: 4.x.x
|
235
249
|
- !ruby/object:Gem::Dependency
|
236
250
|
name: yard
|
237
251
|
requirement: !ruby/object:Gem::Requirement
|
@@ -278,21 +292,23 @@ extra_rdoc_files: []
|
|
278
292
|
files:
|
279
293
|
- History.md
|
280
294
|
- Rakefile
|
295
|
+
- app/app.rb
|
296
|
+
- app/get/config.rb
|
297
|
+
- app/get/objects.rb
|
298
|
+
- app/get/status.rb
|
299
|
+
- app/get/status/hostgroups.rb
|
300
|
+
- app/put.rb
|
301
|
+
- app/put/host.rb
|
302
|
+
- app/put/status.rb
|
281
303
|
- bin/nagira
|
282
304
|
- bin/nagira-setup
|
283
305
|
- config/defaults.rb
|
284
306
|
- config/environment.rb
|
285
307
|
- config/nagira.defaults
|
286
308
|
- config/nagira.init_d
|
287
|
-
- lib/app.rb
|
288
|
-
- lib/app/routes/get/config.rb
|
289
|
-
- lib/app/routes/get/objects.rb
|
290
|
-
- lib/app/routes/get/status.rb
|
291
|
-
- lib/app/routes/put.rb
|
292
|
-
- lib/app/routes/put/host.rb
|
293
|
-
- lib/app/routes/put/status.rb
|
294
309
|
- lib/nagira.rb
|
295
310
|
- lib/nagira/background_parse.rb
|
311
|
+
- lib/nagira/hostgroup.rb
|
296
312
|
- lib/nagira/nagios.rb
|
297
313
|
- lib/nagira/timed_parse.rb
|
298
314
|
- lib/tasks/config.rake
|
@@ -305,6 +321,7 @@ files:
|
|
305
321
|
- spec/01_data_format/03_api_spec.rb
|
306
322
|
- spec/get/comments_spec.rb
|
307
323
|
- spec/get/endpoints_spec.rb
|
324
|
+
- spec/get/hostgroup.rb
|
308
325
|
- spec/get/hosts_spec.rb
|
309
326
|
- spec/get/services_spec.rb
|
310
327
|
- spec/put/host_spec.rb
|
@@ -354,3 +371,4 @@ signing_key:
|
|
354
371
|
specification_version: 4
|
355
372
|
summary: 'Nagira : Nagios RESTful API'
|
356
373
|
test_files: []
|
374
|
+
has_rdoc:
|