flapjack 0.5.1 → 0.5.3

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.
Files changed (55) hide show
  1. data/.gitignore +16 -0
  2. data/Rakefile +72 -32
  3. data/VERSION +1 -0
  4. data/bin/flapjack-netsaint-parser +433 -0
  5. data/bin/flapjack-populator +29 -0
  6. data/bin/flapjack-stats +10 -5
  7. data/{etc → dist/etc}/default/flapjack-notifier +0 -0
  8. data/{etc → dist/etc}/default/flapjack-workers +0 -0
  9. data/{etc → dist/etc}/flapjack/flapjack-notifier.conf.example +0 -0
  10. data/{etc → dist/etc}/flapjack/recipients.conf.example +0 -0
  11. data/{etc → dist/etc}/init.d/flapjack-notifier +0 -0
  12. data/{etc → dist/etc}/init.d/flapjack-workers +7 -7
  13. data/dist/puppet/flapjack/files/.stub +0 -0
  14. data/dist/puppet/flapjack/manifests/common.pp +61 -0
  15. data/dist/puppet/flapjack/manifests/notifier.pp +13 -0
  16. data/dist/puppet/flapjack/manifests/worker.pp +13 -0
  17. data/dist/puppet/flapjack/templates/.stub +0 -0
  18. data/dist/puppet/ruby/manifests/dev.pp +5 -0
  19. data/dist/puppet/ruby/manifests/rubygems.pp +14 -0
  20. data/dist/puppet/sqlite3/manifests/dev.pp +5 -0
  21. data/features/netsaint-config-converter.feature +126 -0
  22. data/features/steps/flapjack-importer_steps.rb +112 -0
  23. data/features/steps/flapjack-netsaint-parser_steps.rb +51 -0
  24. data/features/steps/flapjack-worker-manager_steps.rb +6 -8
  25. data/features/support/env.rb +22 -19
  26. data/flapjack.gemspec +186 -23
  27. data/lib/flapjack.rb +4 -0
  28. data/spec/check_sandbox/echo +3 -0
  29. data/spec/check_sandbox/sandboxed_check +5 -0
  30. data/spec/configs/flapjack-notifier-couchdb.ini +25 -0
  31. data/spec/configs/flapjack-notifier.ini +39 -0
  32. data/spec/configs/recipients.ini +14 -0
  33. data/spec/helpers.rb +15 -0
  34. data/spec/inifile_spec.rb +66 -0
  35. data/spec/mock-notifiers/mock/init.rb +3 -0
  36. data/spec/mock-notifiers/mock/mock.rb +19 -0
  37. data/spec/notifier-directories/spoons/testmailer/init.rb +20 -0
  38. data/spec/notifier_application_spec.rb +222 -0
  39. data/spec/notifier_filters_spec.rb +52 -0
  40. data/spec/notifier_options_multiplexer_spec.rb +71 -0
  41. data/spec/notifier_options_spec.rb +115 -0
  42. data/spec/notifier_spec.rb +57 -0
  43. data/spec/notifiers/mailer_spec.rb +36 -0
  44. data/spec/notifiers/xmpp_spec.rb +36 -0
  45. data/spec/persistence/datamapper_spec.rb +74 -0
  46. data/spec/persistence/mock_persistence_backend.rb +26 -0
  47. data/spec/simple.ini +6 -0
  48. data/spec/spec.opts +4 -0
  49. data/spec/test-filters/blocker.rb +13 -0
  50. data/spec/test-filters/mock.rb +13 -0
  51. data/spec/transports/beanstalkd_spec.rb +44 -0
  52. data/spec/transports/mock_transport.rb +58 -0
  53. data/spec/worker_application_spec.rb +62 -0
  54. data/spec/worker_options_spec.rb +83 -0
  55. metadata +166 -47
@@ -0,0 +1,62 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'flapjack', 'applications', 'worker')
2
+ require File.join(File.dirname(__FILE__), 'helpers')
3
+
4
+ describe "worker application" do
5
+
6
+ it "should have a simple booting interface " do
7
+ options = {:log => MockLogger.new}
8
+ app = Flapjack::Worker::Application.run(options)
9
+ end
10
+
11
+ it "should load beanstalkd as the default transport" do
12
+ options = {:log => MockLogger.new}
13
+ app = Flapjack::Worker::Application.run(options)
14
+
15
+ app.log.messages.find {|msg| msg =~ /loading.+beanstalkd.+transport/i}.should_not be_nil
16
+ end
17
+
18
+ it "should setup two transports (checks + results)" do
19
+ options = {:log => MockLogger.new}
20
+ app = Flapjack::Worker::Application.run(options)
21
+
22
+ app.log.messages.find_all {|msg| msg =~ /loading.+beanstalkd.+transport/i}.size.should == 2
23
+ app.log.messages.find {|msg| msg =~ /loading.+beanstalkd.+transport.+checks/i}.should be_true
24
+ app.log.messages.find {|msg| msg =~ /loading.+beanstalkd.+transport.+results/i}.should be_true
25
+ end
26
+
27
+ it "should load a transport as specified in options" do
28
+ options = {:log => MockLogger.new, :transport => {:backend => :beanstalkd}}
29
+ app = Flapjack::Worker::Application.run(options)
30
+
31
+ app.log.messages.find {|msg| msg =~ /loading.+beanstalkd.+transport/i}.should_not be_nil
32
+ end
33
+
34
+ it "should error if the specified transport dosen't exist" do
35
+ options = {:log => MockLogger.new, :transport => {:backend => :nonexistant}}
36
+ lambda {
37
+ app = Flapjack::Worker::Application.run(options)
38
+ }.should raise_error
39
+ end
40
+
41
+ it "should execute checks in a sandbox"
42
+
43
+ it "should use a limited interface for dealing with transports" do
44
+ options = { :log => MockLogger.new,
45
+ :transport => {:backend => :mock_transport,
46
+ :basedir => File.join(File.dirname(__FILE__), 'transports')} }
47
+ app = Flapjack::Worker::Application.run(options)
48
+ app.process_check
49
+
50
+ # check allowed methods were called
51
+ allowed_methods = %w(next)
52
+ allowed_methods.each do |method|
53
+ app.log.messages.find {|msg| msg =~ /#{method} was called/}.should_not be_nil
54
+ end
55
+
56
+ # check no other methods were called
57
+ called_methods = app.log.messages.find_all {|msg| msg =~ /^method .+ was called on MockTransport$/i }.map {|msg| msg.split(' ')[1]}
58
+ (allowed_methods - called_methods).size.should == 0
59
+ end
60
+
61
+
62
+ end
@@ -0,0 +1,83 @@
1
+ require 'rubygems'
2
+ $: << File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'lib/flapjack/cli/worker'
4
+
5
+ describe Flapjack::WorkerOptions do
6
+
7
+ before(:each) do
8
+ end
9
+
10
+ # beanstalk
11
+ it "should accept the location of a beanstalk queue in short form" do
12
+ args = %w(-b localhost)
13
+ options = Flapjack::WorkerOptions.parse(args)
14
+ options.host.should == "localhost"
15
+ end
16
+
17
+ it "should accept the location of a beanstalk queue in long form" do
18
+ args = %w(--beanstalk localhost)
19
+ options = Flapjack::WorkerOptions.parse(args)
20
+ options.host.should == "localhost"
21
+ end
22
+
23
+ it "should set a default beanstalk host" do
24
+ args = []
25
+ options = Flapjack::WorkerOptions.parse(args)
26
+ options.host.should == 'localhost'
27
+ end
28
+
29
+ # beanstalk port
30
+ it "should accept a specified beanstalk port in short form" do
31
+ args = %w(-b localhost -p 11340)
32
+ options = Flapjack::WorkerOptions.parse(args)
33
+ options.port.should == 11340
34
+ end
35
+
36
+ it "should accept a specified beanstalk port in long form" do
37
+ args = %w(-b localhost --port 11399)
38
+ options = Flapjack::WorkerOptions.parse(args)
39
+ options.port.should == 11399
40
+ end
41
+
42
+ it "should set a default beanstalk port" do
43
+ args = %w(-b localhost)
44
+ options = Flapjack::WorkerOptions.parse(args)
45
+ options.port.should == 11300
46
+ end
47
+
48
+ it "should accept a specified checks directory in short form" do
49
+ args = %w(-c /tmp)
50
+ options = Flapjack::WorkerOptions.parse(args)
51
+ options.checks_directory.should == "/tmp"
52
+ end
53
+
54
+ it "should accept a specified checks directory in long form" do
55
+ args = %w(--checks-directory /tmp)
56
+ options = Flapjack::WorkerOptions.parse(args)
57
+ options.checks_directory.should == "/tmp"
58
+ end
59
+
60
+ it "should set a default checks directory" do
61
+ args = []
62
+ options = Flapjack::WorkerOptions.parse(args)
63
+ options.checks_directory.should_not be_nil
64
+ end
65
+
66
+ # general
67
+ it "should exit on when asked for help in short form" do
68
+ args = %w(-h)
69
+ lambda {
70
+ Flapjack::WorkerOptions.parse(args)
71
+ }.should raise_error(SystemExit)
72
+ end
73
+
74
+ it "should exit on when asked for help in long form" do
75
+ args = %w(--help)
76
+ lambda {
77
+ Flapjack::WorkerOptions.parse(args)
78
+ }.should raise_error(SystemExit)
79
+ end
80
+ end
81
+
82
+
83
+ def puts(*args) ; end
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flapjack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ hash: 13
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 5
9
+ - 3
10
+ version: 0.5.3
5
11
  platform: ruby
6
12
  authors:
7
13
  - Lindsay Holmwood
@@ -9,129 +15,190 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2010-02-28 00:00:00 -05:00
18
+ date: 2011-01-14 00:00:00 +11:00
13
19
  default_executable:
14
20
  dependencies:
15
21
  - !ruby/object:Gem::Dependency
16
22
  name: daemons
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
20
26
  requirements:
21
27
  - - "="
22
28
  - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 1
32
+ - 0
33
+ - 10
23
34
  version: 1.0.10
24
- version:
35
+ type: :runtime
36
+ version_requirements: *id001
25
37
  - !ruby/object:Gem::Dependency
26
38
  name: beanstalk-client
27
- type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
30
42
  requirements:
31
43
  - - "="
32
44
  - !ruby/object:Gem::Version
45
+ hash: 19
46
+ segments:
47
+ - 1
48
+ - 0
49
+ - 2
33
50
  version: 1.0.2
34
- version:
51
+ type: :runtime
52
+ version_requirements: *id002
35
53
  - !ruby/object:Gem::Dependency
36
54
  name: log4r
37
- type: :runtime
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
40
58
  requirements:
41
59
  - - "="
42
60
  - !ruby/object:Gem::Version
61
+ hash: 25
62
+ segments:
63
+ - 1
64
+ - 1
65
+ - 5
43
66
  version: 1.1.5
44
- version:
67
+ type: :runtime
68
+ version_requirements: *id003
45
69
  - !ruby/object:Gem::Dependency
46
70
  name: xmpp4r
47
- type: :runtime
48
- version_requirement:
49
- version_requirements: !ruby/object:Gem::Requirement
71
+ prerelease: false
72
+ requirement: &id004 !ruby/object:Gem::Requirement
73
+ none: false
50
74
  requirements:
51
75
  - - "="
52
76
  - !ruby/object:Gem::Version
77
+ hash: 1
78
+ segments:
79
+ - 0
80
+ - 5
53
81
  version: "0.5"
54
- version:
82
+ type: :runtime
83
+ version_requirements: *id004
55
84
  - !ruby/object:Gem::Dependency
56
85
  name: tmail
57
- type: :runtime
58
- version_requirement:
59
- version_requirements: !ruby/object:Gem::Requirement
86
+ prerelease: false
87
+ requirement: &id005 !ruby/object:Gem::Requirement
88
+ none: false
60
89
  requirements:
61
90
  - - "="
62
91
  - !ruby/object:Gem::Version
92
+ hash: 65
93
+ segments:
94
+ - 1
95
+ - 2
96
+ - 3
97
+ - 1
63
98
  version: 1.2.3.1
64
- version:
99
+ type: :runtime
100
+ version_requirements: *id005
65
101
  - !ruby/object:Gem::Dependency
66
102
  name: yajl-ruby
67
- type: :runtime
68
- version_requirement:
69
- version_requirements: !ruby/object:Gem::Requirement
103
+ prerelease: false
104
+ requirement: &id006 !ruby/object:Gem::Requirement
105
+ none: false
70
106
  requirements:
71
107
  - - "="
72
108
  - !ruby/object:Gem::Version
109
+ hash: 15
110
+ segments:
111
+ - 0
112
+ - 6
113
+ - 4
73
114
  version: 0.6.4
74
- version:
115
+ type: :runtime
116
+ version_requirements: *id006
75
117
  - !ruby/object:Gem::Dependency
76
118
  name: sqlite3-ruby
77
- type: :runtime
78
- version_requirement:
79
- version_requirements: !ruby/object:Gem::Requirement
119
+ prerelease: false
120
+ requirement: &id007 !ruby/object:Gem::Requirement
121
+ none: false
80
122
  requirements:
81
123
  - - "="
82
124
  - !ruby/object:Gem::Version
125
+ hash: 21
126
+ segments:
127
+ - 1
128
+ - 2
129
+ - 5
83
130
  version: 1.2.5
84
- version:
85
- description: Flapjack is highly scalable and distributed monitoring system. It understands the Nagios plugin format, and can easily be scaled from 1 server to 1000.
131
+ type: :runtime
132
+ version_requirements: *id007
133
+ description: lapjack is highly scalable and distributed monitoring system. It understands the Nagios plugin format, and can easily be scaled from 1 server to 1000.
86
134
  email: lindsay@holmwood.id.au
87
135
  executables:
88
136
  - flapjack-benchmark
137
+ - flapjack-netsaint-parser
89
138
  - flapjack-notifier
90
139
  - flapjack-notifier-manager
140
+ - flapjack-populator
91
141
  - flapjack-stats
92
142
  - flapjack-worker
93
143
  - flapjack-worker-manager
94
144
  - install-flapjack-systemwide
95
145
  extensions: []
96
146
 
97
- extra_rdoc_files: []
98
-
147
+ extra_rdoc_files:
148
+ - README.md
99
149
  files:
150
+ - .gitignore
100
151
  - LICENCE
101
152
  - README.md
102
153
  - Rakefile
103
154
  - TODO.md
155
+ - VERSION
104
156
  - bin/flapjack-benchmark
157
+ - bin/flapjack-netsaint-parser
105
158
  - bin/flapjack-notifier
106
159
  - bin/flapjack-notifier-manager
160
+ - bin/flapjack-populator
107
161
  - bin/flapjack-stats
108
162
  - bin/flapjack-worker
109
163
  - bin/flapjack-worker-manager
110
164
  - bin/install-flapjack-systemwide
165
+ - dist/etc/default/flapjack-notifier
166
+ - dist/etc/default/flapjack-workers
167
+ - dist/etc/flapjack/flapjack-notifier.conf.example
168
+ - dist/etc/flapjack/recipients.conf.example
169
+ - dist/etc/init.d/flapjack-notifier
170
+ - dist/etc/init.d/flapjack-workers
171
+ - dist/puppet/flapjack/files/.stub
172
+ - dist/puppet/flapjack/manifests/common.pp
173
+ - dist/puppet/flapjack/manifests/notifier.pp
174
+ - dist/puppet/flapjack/manifests/worker.pp
175
+ - dist/puppet/flapjack/templates/.stub
176
+ - dist/puppet/ruby/manifests/dev.pp
177
+ - dist/puppet/ruby/manifests/rubygems.pp
178
+ - dist/puppet/sqlite3/manifests/dev.pp
111
179
  - doc/CONFIGURING.md
112
180
  - doc/DEVELOPING.md
113
181
  - doc/INSTALL.md
114
182
  - doc/PACKAGING.md
115
- - etc/default/flapjack-notifier
116
- - etc/default/flapjack-workers
117
- - etc/flapjack/flapjack-notifier.conf.example
118
- - etc/flapjack/recipients.conf.example
119
- - etc/init.d/flapjack-notifier
120
- - etc/init.d/flapjack-workers
121
183
  - features/flapjack-notifier-manager.feature
122
184
  - features/flapjack-worker-manager.feature
185
+ - features/netsaint-config-converter.feature
123
186
  - features/packaging-lintian.feature
124
187
  - features/persistence/couch.feature
125
188
  - features/persistence/sqlite3.feature
126
189
  - features/persistence/steps/couch_steps.rb
127
190
  - features/persistence/steps/generic_steps.rb
128
191
  - features/persistence/steps/sqlite3_steps.rb
192
+ - features/steps/flapjack-importer_steps.rb
193
+ - features/steps/flapjack-netsaint-parser_steps.rb
129
194
  - features/steps/flapjack-notifier-manager_steps.rb
130
195
  - features/steps/flapjack-worker-manager_steps.rb
131
196
  - features/steps/packaging-lintian_steps.rb
132
197
  - features/support/env.rb
133
198
  - features/support/silent_system.rb
199
+ - features/support/tmp/.stub
134
200
  - flapjack.gemspec
201
+ - lib/flapjack.rb
135
202
  - lib/flapjack/applications/notifier.rb
136
203
  - lib/flapjack/applications/worker.rb
137
204
  - lib/flapjack/checks/http_content
@@ -163,33 +230,85 @@ files:
163
230
  - lib/flapjack/persistence/sqlite3/sqlite3.rb
164
231
  - lib/flapjack/transports/beanstalkd.rb
165
232
  - lib/flapjack/transports/result.rb
233
+ - spec/check_sandbox/echo
234
+ - spec/check_sandbox/sandboxed_check
235
+ - spec/configs/flapjack-notifier-couchdb.ini
236
+ - spec/configs/flapjack-notifier.ini
237
+ - spec/configs/recipients.ini
238
+ - spec/helpers.rb
239
+ - spec/inifile_spec.rb
240
+ - spec/mock-notifiers/mock/init.rb
241
+ - spec/mock-notifiers/mock/mock.rb
242
+ - spec/notifier-directories/spoons/testmailer/init.rb
243
+ - spec/notifier_application_spec.rb
244
+ - spec/notifier_filters_spec.rb
245
+ - spec/notifier_options_multiplexer_spec.rb
246
+ - spec/notifier_options_spec.rb
247
+ - spec/notifier_spec.rb
248
+ - spec/notifiers/mailer_spec.rb
249
+ - spec/notifiers/xmpp_spec.rb
250
+ - spec/persistence/datamapper_spec.rb
251
+ - spec/persistence/mock_persistence_backend.rb
252
+ - spec/simple.ini
253
+ - spec/spec.opts
254
+ - spec/test-filters/blocker.rb
255
+ - spec/test-filters/mock.rb
256
+ - spec/transports/beanstalkd_spec.rb
257
+ - spec/transports/mock_transport.rb
258
+ - spec/worker_application_spec.rb
259
+ - spec/worker_options_spec.rb
166
260
  has_rdoc: true
167
- homepage: http://flapjack-project.com
261
+ homepage: http://flapjack-project.com/
168
262
  licenses: []
169
263
 
170
264
  post_install_message:
171
- rdoc_options: []
172
-
265
+ rdoc_options:
266
+ - --charset=UTF-8
173
267
  require_paths:
174
268
  - lib
175
269
  required_ruby_version: !ruby/object:Gem::Requirement
270
+ none: false
176
271
  requirements:
177
272
  - - ">="
178
273
  - !ruby/object:Gem::Version
274
+ hash: 3
275
+ segments:
276
+ - 0
179
277
  version: "0"
180
- version:
181
278
  required_rubygems_version: !ruby/object:Gem::Requirement
279
+ none: false
182
280
  requirements:
183
281
  - - ">="
184
282
  - !ruby/object:Gem::Version
283
+ hash: 3
284
+ segments:
285
+ - 0
185
286
  version: "0"
186
- version:
187
287
  requirements: []
188
288
 
189
289
  rubyforge_project:
190
- rubygems_version: 1.3.5
290
+ rubygems_version: 1.3.7
191
291
  signing_key:
192
292
  specification_version: 3
193
293
  summary: a scalable and distributed monitoring system
194
- test_files: []
195
-
294
+ test_files:
295
+ - spec/helpers.rb
296
+ - spec/inifile_spec.rb
297
+ - spec/mock-notifiers/mock/init.rb
298
+ - spec/mock-notifiers/mock/mock.rb
299
+ - spec/notifier-directories/spoons/testmailer/init.rb
300
+ - spec/notifier_application_spec.rb
301
+ - spec/notifier_filters_spec.rb
302
+ - spec/notifier_options_multiplexer_spec.rb
303
+ - spec/notifier_options_spec.rb
304
+ - spec/notifier_spec.rb
305
+ - spec/notifiers/mailer_spec.rb
306
+ - spec/notifiers/xmpp_spec.rb
307
+ - spec/persistence/datamapper_spec.rb
308
+ - spec/persistence/mock_persistence_backend.rb
309
+ - spec/test-filters/blocker.rb
310
+ - spec/test-filters/mock.rb
311
+ - spec/transports/beanstalkd_spec.rb
312
+ - spec/transports/mock_transport.rb
313
+ - spec/worker_application_spec.rb
314
+ - spec/worker_options_spec.rb