flapjack 0.9.6 → 1.0.0rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.rspec +6 -0
- data/.travis.yml +20 -16
- data/CHANGELOG.md +11 -25
- data/Dockerfile +8 -0
- data/Gemfile +2 -5
- data/bin/flapjack +24 -213
- data/etc/flapjack_config.yaml.example +6 -30
- data/features/cli.feature +16 -14
- data/features/cli_flapjack-feed-events.feature +12 -13
- data/features/cli_flapjack-nagios-receiver.feature +14 -15
- data/features/cli_flapjack-populator.feature +16 -15
- data/features/cli_flapper.feature +12 -12
- data/features/cli_receive-events.feature +6 -5
- data/features/cli_simulate-failed-check.feature +7 -6
- data/features/steps/cli_steps.rb +2 -2
- data/features/support/env.rb +1 -0
- data/flapjack.gemspec +1 -0
- data/lib/flapjack/cli/flapper.rb +200 -0
- data/lib/flapjack/cli/import.rb +102 -0
- data/lib/flapjack/cli/receiver.rb +656 -0
- data/lib/flapjack/cli/server.rb +256 -0
- data/lib/flapjack/cli/simulate.rb +180 -0
- data/lib/flapjack/configuration.rb +2 -0
- data/lib/flapjack/data/entity_check.rb +5 -22
- data/lib/flapjack/data/event.rb +7 -12
- data/lib/flapjack/gateways/email.rb +4 -1
- data/lib/flapjack/gateways/jabber.rb +12 -36
- data/lib/flapjack/gateways/jsonapi/check_presenter.rb +6 -6
- data/lib/flapjack/gateways/jsonapi/report_methods.rb +5 -3
- data/lib/flapjack/gateways/pagerduty.rb +1 -1
- data/lib/flapjack/gateways/web/public/js/backbone.jsonapi.js +1 -1
- data/lib/flapjack/gateways/web/public/js/modules/contact.js +2 -2
- data/lib/flapjack/gateways/web/public/js/modules/entity.js +2 -2
- data/lib/flapjack/gateways/web/public/js/modules/medium.js +4 -4
- data/lib/flapjack/gateways/web/public/js/self_stats.js +1 -1
- data/lib/flapjack/gateways/web/views/check.html.erb +7 -7
- data/lib/flapjack/gateways/web/views/checks.html.erb +2 -3
- data/lib/flapjack/gateways/web/views/contact.html.erb +4 -4
- data/lib/flapjack/gateways/web/views/contacts.html.erb +2 -2
- data/lib/flapjack/gateways/web/views/edit_contacts.html.erb +1 -1
- data/lib/flapjack/gateways/web/views/entities.html.erb +1 -1
- data/lib/flapjack/gateways/web/views/entity.html.erb +1 -1
- data/lib/flapjack/gateways/web/views/index.html.erb +2 -2
- data/lib/flapjack/gateways/web/views/layout.erb +10 -10
- data/lib/flapjack/gateways/web/views/self_stats.html.erb +1 -1
- data/lib/flapjack/gateways/web.rb +36 -7
- data/lib/flapjack/pikelet.rb +0 -2
- data/lib/flapjack/processor.rb +3 -1
- data/lib/flapjack/redis_pool.rb +2 -6
- data/lib/flapjack/version.rb +1 -1
- data/spec/lib/flapjack/coordinator_spec.rb +3 -3
- data/spec/lib/flapjack/data/entity_check_spec.rb +2 -6
- data/spec/lib/flapjack/data/event_spec.rb +0 -31
- data/spec/lib/flapjack/gateways/email_spec.rb +109 -0
- data/spec/lib/flapjack/gateways/jabber_spec.rb +18 -16
- data/spec/lib/flapjack/gateways/jsonapi/check_presenter_spec.rb +12 -24
- data/spec/lib/flapjack/gateways/pagerduty_spec.rb +1 -1
- data/spec/lib/flapjack/gateways/web/views/check.html.erb_spec.rb +2 -0
- data/spec/lib/flapjack/gateways/web/views/contact.html.erb_spec.rb +2 -0
- data/spec/lib/flapjack/gateways/web/views/index.html.erb_spec.rb +2 -0
- data/spec/lib/flapjack/gateways/web_spec.rb +194 -145
- data/spec/lib/flapjack/redis_pool_spec.rb +0 -1
- data/spec/support/profile_all_formatter.rb +44 -0
- data/spec/support/uncolored_doc_formatter.rb +9 -0
- data/tasks/benchmarks.rake +0 -4
- metadata +28 -38
- data/.ruby-version +0 -1
- data/Gemfile-ruby1.9 +0 -28
- data/Gemfile-ruby1.9.lock +0 -227
- data/bin/flapjack-feed-events +0 -124
- data/bin/flapjack-nagios-receiver +0 -246
- data/bin/flapjack-nsca-receiver +0 -246
- data/bin/flapjack-populator +0 -132
- data/bin/flapper +0 -152
- data/bin/receive-events +0 -179
- data/bin/simulate-failed-check +0 -151
- data/lib/flapjack/data/migration.rb +0 -36
- data/lib/flapjack/gateways/api/contact_methods.rb +0 -369
- data/lib/flapjack/gateways/api/entity_check_presenter.rb +0 -218
- data/lib/flapjack/gateways/api/entity_methods.rb +0 -361
- data/lib/flapjack/gateways/api/entity_presenter.rb +0 -75
- data/lib/flapjack/gateways/api/rack/json_params_parser.rb +0 -26
- data/lib/flapjack/gateways/api.rb +0 -124
- data/spec/lib/flapjack/gateways/api/contact_methods_spec.rb +0 -772
- data/spec/lib/flapjack/gateways/api/entity_check_presenter_spec.rb +0 -211
- data/spec/lib/flapjack/gateways/api/entity_methods_spec.rb +0 -863
- data/spec/lib/flapjack/gateways/api/entity_presenter_spec.rb +0 -108
- data/spec/lib/flapjack/gateways/api_spec.rb +0 -30
@@ -23,13 +23,6 @@ describe Flapjack::Gateways::Web, :sinatra => true, :logger => true do
|
|
23
23
|
}
|
24
24
|
end
|
25
25
|
|
26
|
-
before(:each) do
|
27
|
-
expect(Flapjack::RedisPool).to receive(:new).and_return(redis)
|
28
|
-
Flapjack::Gateways::Web.instance_variable_set('@config', {})
|
29
|
-
Flapjack::Gateways::Web.instance_variable_set('@logger', @logger)
|
30
|
-
Flapjack::Gateways::Web.start
|
31
|
-
end
|
32
|
-
|
33
26
|
def expect_stats
|
34
27
|
expect(redis).to receive(:dbsize).and_return(3)
|
35
28
|
expect(redis).to receive(:keys).with('executive_instance:*').and_return(["executive_instance:foo-app-01"])
|
@@ -69,186 +62,242 @@ describe Flapjack::Gateways::Web, :sinatra => true, :logger => true do
|
|
69
62
|
expect(ec).to receive(:in_unscheduled_maintenance?).and_return(false)
|
70
63
|
end
|
71
64
|
|
72
|
-
|
73
|
-
# (for the methods that access redis directly)
|
65
|
+
context "Web page design" do
|
74
66
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
expect_check_stats
|
67
|
+
before(:each) do
|
68
|
+
expect(Flapjack::RedisPool).to receive(:new).and_return(redis)
|
69
|
+
Flapjack::Gateways::Web.instance_variable_set('@logger', @logger)
|
70
|
+
end
|
80
71
|
|
81
|
-
|
72
|
+
it "displays a custom logo if configured" do
|
73
|
+
image_path = '/tmp/branding.png'
|
74
|
+
config = {"logo_image_path" => image_path}
|
82
75
|
|
83
|
-
|
84
|
-
|
76
|
+
allow(File).to receive(:file?).and_call_original
|
77
|
+
allow(File).to receive(:file?).with(image_path) { true }
|
85
78
|
|
86
|
-
|
87
|
-
|
79
|
+
Flapjack::Gateways::Web.instance_variable_set('@config', config)
|
80
|
+
Flapjack::Gateways::Web.start
|
88
81
|
|
89
|
-
|
90
|
-
|
91
|
-
|
82
|
+
# NOTE Reuse enough of the stats specs to be able to build a page quickly
|
83
|
+
expect_stats
|
84
|
+
expect_check_stats
|
85
|
+
expect_entity_stats
|
86
|
+
|
87
|
+
logo_image_tag = '<img alt="Flapjack" class="logo" src="/img/branding.png">'
|
92
88
|
|
93
|
-
|
94
|
-
#redis.should_receive(:zrange).with('failed_checks', 0, -1).and_return(["#{entity_name}:#{check}"])
|
89
|
+
aget '/self_stats'
|
95
90
|
|
96
|
-
|
91
|
+
expect( last_response.body ).to include(logo_image_tag)
|
92
|
+
end
|
97
93
|
|
98
|
-
|
94
|
+
it "displays the standard logo if no custom logo configured" do
|
95
|
+
Flapjack::Gateways::Web.instance_variable_set('@config', {})
|
96
|
+
Flapjack::Gateways::Web.start
|
97
|
+
# NOTE Reuse enough of the stats specs to be able to build a page quickly
|
98
|
+
expect_stats
|
99
|
+
expect_check_stats
|
100
|
+
expect_entity_stats
|
99
101
|
|
100
|
-
|
101
|
-
with(entity_name, :redis => redis).and_return(entity)
|
102
|
+
logo_image_tag = '<img alt="Flapjack" class="logo" src="/img/flapjack-2013-notext-transparent-300-300.png">'
|
102
103
|
|
103
|
-
|
104
|
-
with(:redis => redis).and_return({entity_name => [check]})
|
104
|
+
aget '/self_stats'
|
105
105
|
|
106
|
-
|
107
|
-
|
108
|
-
aget '/checks_failing'
|
109
|
-
expect(last_response).to be_ok
|
106
|
+
expect( last_response.body ).to include(logo_image_tag)
|
107
|
+
end
|
110
108
|
end
|
111
109
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
110
|
+
context "Web page behavior" do
|
111
|
+
|
112
|
+
before(:each) do
|
113
|
+
expect(Flapjack::RedisPool).to receive(:new).and_return(redis)
|
114
|
+
Flapjack::Gateways::Web.instance_variable_set('@config', {})
|
115
|
+
Flapjack::Gateways::Web.instance_variable_set('@logger', @logger)
|
116
|
+
Flapjack::Gateways::Web.start
|
117
|
+
end
|
118
|
+
|
119
|
+
# TODO add data, test that pages contain representations of it
|
120
|
+
# (for the methods that access redis directly)
|
121
|
+
|
122
|
+
it "shows a page listing all checks" do
|
123
|
+
#redis.should_receive(:keys).with('*:*:states').and_return(["#{entity_name}:#{check}"])
|
124
|
+
expect(Flapjack::Data::EntityCheck).to receive(:find_all_by_entity).
|
125
|
+
with(:redis => redis).and_return({entity_name => [check]})
|
126
|
+
expect_check_stats
|
127
|
+
|
128
|
+
expect_entity_check_status(entity_check)
|
129
|
+
|
130
|
+
expect(Flapjack::Data::Entity).to receive(:find_by_name).
|
131
|
+
with(entity_name, :redis => redis).and_return(entity)
|
132
|
+
|
133
|
+
expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
|
134
|
+
with(entity, 'ping', :redis => redis).and_return(entity_check)
|
135
|
+
|
136
|
+
aget '/checks_all'
|
137
|
+
expect(last_response).to be_ok
|
138
|
+
end
|
139
|
+
|
140
|
+
it "shows a page listing failing checks" do
|
141
|
+
#redis.should_receive(:zrange).with('failed_checks', 0, -1).and_return(["#{entity_name}:#{check}"])
|
142
|
+
|
143
|
+
expect_check_stats
|
144
|
+
|
145
|
+
expect_entity_check_status(entity_check)
|
146
|
+
|
147
|
+
expect(Flapjack::Data::Entity).to receive(:find_by_name).
|
148
|
+
with(entity_name, :redis => redis).and_return(entity)
|
149
|
+
|
150
|
+
expect(Flapjack::Data::EntityCheck).to receive(:find_all_failing_by_entity).
|
151
|
+
with(:redis => redis).and_return({entity_name => [check]})
|
152
|
+
|
153
|
+
expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
|
154
|
+
with(entity, 'ping', :redis => redis).and_return(entity_check)
|
155
|
+
aget '/checks_failing'
|
156
|
+
expect(last_response).to be_ok
|
157
|
+
end
|
118
158
|
|
119
|
-
|
120
|
-
|
121
|
-
|
159
|
+
it "shows a page listing flapjack statistics" do
|
160
|
+
#redis.should_receive(:keys).with('check:*').and_return([])
|
161
|
+
#redis.should_receive(:zrange).with('failed_checks', 0, -1).and_return(["#{entity_name}:#{check}"])
|
162
|
+
expect_stats
|
163
|
+
expect_check_stats
|
164
|
+
expect_entity_stats
|
122
165
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
last_notifications = {:problem => {:timestamp => time.to_i - ((3 * 60 * 60) + (5 * 60)), :summary => 'prob'},
|
128
|
-
:recovery => {:timestamp => time.to_i - (3 * 60 * 60), :summary => nil},
|
129
|
-
:acknowledgement => {:timestamp => nil, :summary => nil} }
|
130
|
-
|
131
|
-
expect_check_stats
|
132
|
-
expect(entity_check).to receive(:state).and_return('ok')
|
133
|
-
expect(entity_check).to receive(:last_update).and_return(time.to_i - (3 * 60 * 60))
|
134
|
-
expect(entity_check).to receive(:last_change).and_return(time.to_i - (3 * 60 * 60))
|
135
|
-
expect(entity_check).to receive(:summary).and_return('all good')
|
136
|
-
expect(entity_check).to receive(:details).and_return('seriously, all very wonderful')
|
137
|
-
expect(entity_check).to receive(:perfdata).and_return([{"key" => "foo", "value" => "bar"}])
|
138
|
-
expect(entity_check).to receive(:last_notifications_of_each_type).and_return(last_notifications)
|
139
|
-
expect(entity_check).to receive(:maintenances).with(nil, nil, :scheduled => true).and_return([])
|
140
|
-
expect(entity_check).to receive(:failed?).and_return(false)
|
141
|
-
expect(entity_check).to receive(:current_maintenance).with(:scheduled => true).and_return(false)
|
142
|
-
expect(entity_check).to receive(:current_maintenance).with(:scheduled => false).and_return(false)
|
143
|
-
expect(entity_check).to receive(:contacts).and_return([])
|
144
|
-
expect(entity_check).to receive(:historical_states).
|
145
|
-
with(nil, time.to_i, :order => 'desc', :limit => 20).and_return([])
|
146
|
-
expect(entity_check).to receive(:enabled?).and_return(true)
|
147
|
-
|
148
|
-
expect(Flapjack::Data::Entity).to receive(:find_by_name).
|
149
|
-
with(entity_name, :redis => redis).and_return(entity)
|
150
|
-
|
151
|
-
expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
|
152
|
-
with(entity, 'ping', :redis => redis).and_return(entity_check)
|
153
|
-
|
154
|
-
aget "/check?entity=#{entity_name_esc}&check=ping"
|
155
|
-
expect(last_response).to be_ok
|
156
|
-
# TODO test instance variables set to appropriate values
|
157
|
-
end
|
166
|
+
aget '/self_stats'
|
167
|
+
expect(last_response).to be_ok
|
168
|
+
end
|
158
169
|
|
159
|
-
|
160
|
-
|
161
|
-
|
170
|
+
it "shows the state of a check for an entity" do
|
171
|
+
time = Time.now
|
172
|
+
expect(Time).to receive(:now).exactly(5).times.and_return(time)
|
162
173
|
|
163
|
-
|
164
|
-
|
165
|
-
|
174
|
+
last_notifications = {:problem => {:timestamp => time.to_i - ((3 * 60 * 60) + (5 * 60)), :summary => 'prob'},
|
175
|
+
:recovery => {:timestamp => time.to_i - (3 * 60 * 60), :summary => nil},
|
176
|
+
:acknowledgement => {:timestamp => nil, :summary => nil} }
|
166
177
|
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
178
|
+
expect_check_stats
|
179
|
+
expect(entity_check).to receive(:state).and_return('ok')
|
180
|
+
expect(entity_check).to receive(:last_update).and_return(time.to_i - (3 * 60 * 60))
|
181
|
+
expect(entity_check).to receive(:last_change).and_return(time.to_i - (3 * 60 * 60))
|
182
|
+
expect(entity_check).to receive(:summary).and_return('all good')
|
183
|
+
expect(entity_check).to receive(:details).and_return('seriously, all very wonderful')
|
184
|
+
expect(entity_check).to receive(:perfdata).and_return([{"key" => "foo", "value" => "bar"}])
|
185
|
+
expect(entity_check).to receive(:last_notifications_of_each_type).and_return(last_notifications)
|
186
|
+
expect(entity_check).to receive(:maintenances).with(nil, nil, :scheduled => true).and_return([])
|
187
|
+
expect(entity_check).to receive(:failed?).and_return(false)
|
188
|
+
expect(entity_check).to receive(:current_maintenance).with(:scheduled => true).and_return(false)
|
189
|
+
expect(entity_check).to receive(:current_maintenance).with(:scheduled => false).and_return(false)
|
190
|
+
expect(entity_check).to receive(:contacts).and_return([])
|
191
|
+
expect(entity_check).to receive(:historical_states).
|
192
|
+
with(nil, time.to_i, :order => 'desc', :limit => 20).and_return([])
|
193
|
+
expect(entity_check).to receive(:enabled?).and_return(true)
|
171
194
|
|
172
|
-
|
173
|
-
|
174
|
-
end
|
195
|
+
expect(Flapjack::Data::Entity).to receive(:find_by_name).
|
196
|
+
with(entity_name, :redis => redis).and_return(entity)
|
175
197
|
|
176
|
-
|
177
|
-
|
178
|
-
with(entity_name, :redis => redis).and_return(entity)
|
198
|
+
expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
|
199
|
+
with(entity, 'ping', :redis => redis).and_return(entity_check)
|
179
200
|
|
180
|
-
|
181
|
-
|
201
|
+
aget "/check?entity=#{entity_name_esc}&check=ping"
|
202
|
+
expect(last_response).to be_ok
|
203
|
+
# TODO test instance variables set to appropriate values
|
204
|
+
end
|
182
205
|
|
183
|
-
|
184
|
-
|
185
|
-
|
206
|
+
it "returns 404 if an unknown entity is requested" do
|
207
|
+
expect(Flapjack::Data::Entity).to receive(:find_by_name).
|
208
|
+
with(entity_name_esc, :redis => redis).and_return(nil)
|
186
209
|
|
187
|
-
|
188
|
-
|
189
|
-
|
210
|
+
aget "/check?entity=#{entity_name_esc}&check=ping"
|
211
|
+
expect(last_response).to be_not_found
|
212
|
+
end
|
190
213
|
|
191
|
-
|
192
|
-
|
214
|
+
# TODO shouldn't create actual entity record
|
215
|
+
it "returns 404 if no entity check is passed" do
|
216
|
+
expect(Flapjack::Data::Entity).to receive(:find_by_name).
|
217
|
+
with(entity_name, :redis => redis).and_return(entity)
|
193
218
|
|
194
|
-
|
195
|
-
|
196
|
-
|
219
|
+
aget "/check?entity=#{entity_name_esc}"
|
220
|
+
expect(last_response).to be_not_found
|
221
|
+
end
|
197
222
|
|
198
|
-
|
199
|
-
|
223
|
+
it "creates an acknowledgement for an entity check" do
|
224
|
+
expect(Flapjack::Data::Entity).to receive(:find_by_name).
|
225
|
+
with(entity_name, :redis => redis).and_return(entity)
|
200
226
|
|
201
|
-
|
202
|
-
|
227
|
+
expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
|
228
|
+
with(entity, 'ping', :redis => redis).and_return(entity_check)
|
203
229
|
|
204
|
-
|
205
|
-
|
230
|
+
expect(Flapjack::Data::Event).to receive(:create_acknowledgement).
|
231
|
+
with(entity_name, 'ping', :summary => "", :duration => (4 * 60 * 60),
|
232
|
+
:acknowledgement_id => '1234', :redis => redis)
|
206
233
|
|
207
|
-
|
208
|
-
|
234
|
+
apost "/acknowledgements/#{entity_name_esc}/ping?acknowledgement_id=1234"
|
235
|
+
expect(last_response.status).to eq(302)
|
236
|
+
end
|
209
237
|
|
210
|
-
|
211
|
-
|
238
|
+
it "creates a scheduled maintenance period for an entity check" do
|
239
|
+
t = Time.now.to_i
|
212
240
|
|
213
|
-
|
214
|
-
|
241
|
+
start_time = Time.at(t - (24 * 60 * 60))
|
242
|
+
duration = 30 * 60
|
243
|
+
summary = 'wow'
|
215
244
|
|
216
|
-
|
217
|
-
|
245
|
+
expect(Chronic).to receive(:parse).with('1 day ago').and_return(start_time)
|
246
|
+
expect(ChronicDuration).to receive(:parse).with('30 minutes').and_return(duration)
|
247
|
+
|
248
|
+
expect(Flapjack::Data::Entity).to receive(:find_by_name).
|
249
|
+
with(entity_name, :redis => redis).and_return(entity)
|
250
|
+
|
251
|
+
expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
|
252
|
+
with(entity, 'ping', :redis => redis).and_return(entity_check)
|
253
|
+
|
254
|
+
expect(entity_check).to receive(:create_scheduled_maintenance).
|
255
|
+
with(start_time.to_i, duration, :summary => summary)
|
256
|
+
|
257
|
+
apost "/scheduled_maintenances/#{entity_name_esc}/ping?"+
|
258
|
+
"start_time=1+day+ago&duration=30+minutes&summary=wow"
|
259
|
+
|
260
|
+
expect(last_response.status).to eq(302)
|
261
|
+
end
|
218
262
|
|
219
|
-
|
263
|
+
it "deletes a scheduled maintenance period for an entity check" do
|
264
|
+
t = Time.now.to_i
|
220
265
|
|
221
|
-
|
222
|
-
with(entity_name, :redis => redis).and_return(entity)
|
266
|
+
start_time = t - (24 * 60 * 60)
|
223
267
|
|
224
|
-
|
225
|
-
|
268
|
+
expect(Flapjack::Data::Entity).to receive(:find_by_name).
|
269
|
+
with(entity_name, :redis => redis).and_return(entity)
|
226
270
|
|
227
|
-
|
271
|
+
expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
|
272
|
+
with(entity, 'ping', :redis => redis).and_return(entity_check)
|
228
273
|
|
229
|
-
|
230
|
-
expect(last_response.status).to eq(302)
|
231
|
-
end
|
274
|
+
expect(entity_check).to receive(:end_scheduled_maintenance).with(start_time)
|
232
275
|
|
233
|
-
|
234
|
-
|
276
|
+
adelete "/scheduled_maintenances/#{entity_name_esc}/ping?start_time=#{start_time}"
|
277
|
+
expect(last_response.status).to eq(302)
|
278
|
+
end
|
235
279
|
|
236
|
-
|
237
|
-
|
238
|
-
|
280
|
+
it "shows a list of all known contacts" do
|
281
|
+
expect(Flapjack::Data::Contact).to receive(:all)
|
282
|
+
|
283
|
+
aget "/contacts"
|
284
|
+
expect(last_response).to be_ok
|
285
|
+
end
|
239
286
|
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
287
|
+
it "shows details of an individual contact found by id" do
|
288
|
+
contact = double('contact')
|
289
|
+
expect(contact).to receive(:name).and_return("Smithson Smith")
|
290
|
+
expect(contact).to receive(:media).exactly(3).times.and_return({})
|
291
|
+
expect(contact).to receive(:entities).with(:checks => true).and_return([])
|
292
|
+
expect(contact).to receive(:notification_rules).and_return([])
|
246
293
|
|
247
|
-
|
248
|
-
|
294
|
+
expect(Flapjack::Data::Contact).to receive(:find_by_id).
|
295
|
+
with('0362', :redis => redis).and_return(contact)
|
249
296
|
|
250
|
-
|
251
|
-
|
297
|
+
aget "/contacts/0362"
|
298
|
+
expect(last_response).to be_ok
|
299
|
+
end
|
252
300
|
end
|
253
301
|
|
302
|
+
|
254
303
|
end
|
@@ -12,7 +12,6 @@ describe Flapjack::RedisPool do
|
|
12
12
|
redis
|
13
13
|
}
|
14
14
|
expect(::Redis).to receive(:new).exactly(redis_count).times.and_return(*redis_conns)
|
15
|
-
expect(Flapjack::Data::Migration).to receive(:refresh_archive_index).exactly(redis_count).times
|
16
15
|
|
17
16
|
frp = Flapjack::RedisPool.new(:size => redis_count)
|
18
17
|
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'rspec/core/formatters/base_formatter'
|
2
|
+
|
3
|
+
class ProfileAllFormatter < RSpec::Core::Formatters::BaseFormatter
|
4
|
+
|
5
|
+
def initialize(output)
|
6
|
+
super(output)
|
7
|
+
@example_times = []
|
8
|
+
end
|
9
|
+
|
10
|
+
def start(count)
|
11
|
+
super(count)
|
12
|
+
@output.puts "Profiling enabled."
|
13
|
+
end
|
14
|
+
|
15
|
+
def example_started(example)
|
16
|
+
super(example)
|
17
|
+
@time = ((Time.respond_to?(:zone) && Time.zone) ? Time.zone.now : Time.now)
|
18
|
+
end
|
19
|
+
|
20
|
+
def example_passed(example)
|
21
|
+
@example_times << [
|
22
|
+
example_group.description,
|
23
|
+
example.description,
|
24
|
+
((Time.respond_to?(:zone) && Time.zone) ? Time.zone.now : Time.now) - @time
|
25
|
+
]
|
26
|
+
super(example)
|
27
|
+
end
|
28
|
+
|
29
|
+
def start_dump
|
30
|
+
super
|
31
|
+
@output.puts "\n\nExample times:\n"
|
32
|
+
|
33
|
+
@example_times = @example_times.sort_by do |description, example, time|
|
34
|
+
time
|
35
|
+
end.reverse
|
36
|
+
|
37
|
+
@example_times.each do |description, example, time|
|
38
|
+
@output.print sprintf("%.7f", time)
|
39
|
+
@output.puts " #{description} #{example}"
|
40
|
+
end
|
41
|
+
@output.flush
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
data/tasks/benchmarks.rake
CHANGED
@@ -94,10 +94,6 @@ namespace :benchmarks do
|
|
94
94
|
# - time to failure varies evenly between 1 hour and 1 month
|
95
95
|
# - time to recovery varies evenly between 10 seconds and 1 week
|
96
96
|
task :benchmark do
|
97
|
-
unless RUBY_VERSION.split('.')[0] == '1' && RUBY_VERSION.split('.')[1] == '9'
|
98
|
-
# Flapjack doesn't support 1.8 or below, so just checking for 1.9 is OK
|
99
|
-
raise "perftools.rb doesn't work on Ruby 2.0 or greater"
|
100
|
-
end
|
101
97
|
|
102
98
|
num_checks_per_entity = (ENV['CHECKS_PER_ENTITY'] || 5).to_i
|
103
99
|
num_entities = (ENV['ENTITIES'] || 100).to_i
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flapjack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lindsay Holmwood
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-
|
13
|
+
date: 2014-06-25 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: dante
|
@@ -320,44 +320,42 @@ dependencies:
|
|
320
320
|
- - ">="
|
321
321
|
- !ruby/object:Gem::Version
|
322
322
|
version: '0'
|
323
|
+
- !ruby/object:Gem::Dependency
|
324
|
+
name: gli
|
325
|
+
requirement: !ruby/object:Gem::Requirement
|
326
|
+
requirements:
|
327
|
+
- - ">="
|
328
|
+
- !ruby/object:Gem::Version
|
329
|
+
version: '0'
|
330
|
+
type: :runtime
|
331
|
+
prerelease: false
|
332
|
+
version_requirements: !ruby/object:Gem::Requirement
|
333
|
+
requirements:
|
334
|
+
- - ">="
|
335
|
+
- !ruby/object:Gem::Version
|
336
|
+
version: '0'
|
323
337
|
description: Flapjack is a distributed monitoring notification system that provides
|
324
338
|
a scalable method for processing streams of events from Nagios and deciding who
|
325
339
|
should be notified
|
326
340
|
email: lindsay@holmwood.id.au
|
327
341
|
executables:
|
328
342
|
- flapjack
|
329
|
-
- flapjack-feed-events
|
330
|
-
- flapjack-nagios-receiver
|
331
|
-
- flapjack-nsca-receiver
|
332
|
-
- flapjack-populator
|
333
|
-
- flapper
|
334
|
-
- receive-events
|
335
|
-
- simulate-failed-check
|
336
343
|
extensions: []
|
337
344
|
extra_rdoc_files: []
|
338
345
|
files:
|
339
346
|
- ".gitignore"
|
340
347
|
- ".gitmodules"
|
341
348
|
- ".rspec"
|
342
|
-
- ".ruby-version"
|
343
349
|
- ".travis.yml"
|
344
350
|
- CHANGELOG.md
|
345
351
|
- CONTRIBUTING.md
|
352
|
+
- Dockerfile
|
346
353
|
- Gemfile
|
347
|
-
- Gemfile-ruby1.9
|
348
|
-
- Gemfile-ruby1.9.lock
|
349
354
|
- Guardfile
|
350
355
|
- LICENCE
|
351
356
|
- README.md
|
352
357
|
- Rakefile
|
353
358
|
- bin/flapjack
|
354
|
-
- bin/flapjack-feed-events
|
355
|
-
- bin/flapjack-nagios-receiver
|
356
|
-
- bin/flapjack-nsca-receiver
|
357
|
-
- bin/flapjack-populator
|
358
|
-
- bin/flapper
|
359
|
-
- bin/receive-events
|
360
|
-
- bin/simulate-failed-check
|
361
359
|
- dist/etc/init.d/flapjack
|
362
360
|
- dist/etc/init.d/flapjack-nagios-receiver
|
363
361
|
- dist/etc/init.d/flapper
|
@@ -386,6 +384,11 @@ files:
|
|
386
384
|
- features/support/silent_system.rb
|
387
385
|
- flapjack.gemspec
|
388
386
|
- lib/flapjack.rb
|
387
|
+
- lib/flapjack/cli/flapper.rb
|
388
|
+
- lib/flapjack/cli/import.rb
|
389
|
+
- lib/flapjack/cli/receiver.rb
|
390
|
+
- lib/flapjack/cli/server.rb
|
391
|
+
- lib/flapjack/cli/simulate.rb
|
389
392
|
- lib/flapjack/configuration.rb
|
390
393
|
- lib/flapjack/coordinator.rb
|
391
394
|
- lib/flapjack/data/alert.rb
|
@@ -394,7 +397,6 @@ files:
|
|
394
397
|
- lib/flapjack/data/entity_check.rb
|
395
398
|
- lib/flapjack/data/event.rb
|
396
399
|
- lib/flapjack/data/message.rb
|
397
|
-
- lib/flapjack/data/migration.rb
|
398
400
|
- lib/flapjack/data/notification.rb
|
399
401
|
- lib/flapjack/data/notification_rule.rb
|
400
402
|
- lib/flapjack/data/semaphore.rb
|
@@ -406,12 +408,6 @@ files:
|
|
406
408
|
- lib/flapjack/filters/ok.rb
|
407
409
|
- lib/flapjack/filters/scheduled_maintenance.rb
|
408
410
|
- lib/flapjack/filters/unscheduled_maintenance.rb
|
409
|
-
- lib/flapjack/gateways/api.rb
|
410
|
-
- lib/flapjack/gateways/api/contact_methods.rb
|
411
|
-
- lib/flapjack/gateways/api/entity_check_presenter.rb
|
412
|
-
- lib/flapjack/gateways/api/entity_methods.rb
|
413
|
-
- lib/flapjack/gateways/api/entity_presenter.rb
|
414
|
-
- lib/flapjack/gateways/api/rack/json_params_parser.rb
|
415
411
|
- lib/flapjack/gateways/email.rb
|
416
412
|
- lib/flapjack/gateways/email/alert.html.erb
|
417
413
|
- lib/flapjack/gateways/email/alert.text.erb
|
@@ -521,11 +517,6 @@ files:
|
|
521
517
|
- spec/lib/flapjack/filters/ok_spec.rb
|
522
518
|
- spec/lib/flapjack/filters/scheduled_maintenance_spec.rb
|
523
519
|
- spec/lib/flapjack/filters/unscheduled_maintenance_spec.rb
|
524
|
-
- spec/lib/flapjack/gateways/api/contact_methods_spec.rb
|
525
|
-
- spec/lib/flapjack/gateways/api/entity_check_presenter_spec.rb
|
526
|
-
- spec/lib/flapjack/gateways/api/entity_methods_spec.rb
|
527
|
-
- spec/lib/flapjack/gateways/api/entity_presenter_spec.rb
|
528
|
-
- spec/lib/flapjack/gateways/api_spec.rb
|
529
520
|
- spec/lib/flapjack/gateways/email_spec.rb
|
530
521
|
- spec/lib/flapjack/gateways/jabber_spec.rb
|
531
522
|
- spec/lib/flapjack/gateways/jsonapi/check_methods_spec.rb
|
@@ -553,6 +544,8 @@ files:
|
|
553
544
|
- spec/spec_helper.rb
|
554
545
|
- spec/support/erb_view_helper.rb
|
555
546
|
- spec/support/jsonapi_helper.rb
|
547
|
+
- spec/support/profile_all_formatter.rb
|
548
|
+
- spec/support/uncolored_doc_formatter.rb
|
556
549
|
- tasks/benchmarks.rake
|
557
550
|
- tasks/events.rake
|
558
551
|
- tasks/profile.rake
|
@@ -589,9 +582,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
589
582
|
version: '0'
|
590
583
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
591
584
|
requirements:
|
592
|
-
- - "
|
585
|
+
- - ">"
|
593
586
|
- !ruby/object:Gem::Version
|
594
|
-
version:
|
587
|
+
version: 1.3.1
|
595
588
|
requirements: []
|
596
589
|
rubyforge_project:
|
597
590
|
rubygems_version: 2.2.2
|
@@ -636,11 +629,6 @@ test_files:
|
|
636
629
|
- spec/lib/flapjack/filters/ok_spec.rb
|
637
630
|
- spec/lib/flapjack/filters/scheduled_maintenance_spec.rb
|
638
631
|
- spec/lib/flapjack/filters/unscheduled_maintenance_spec.rb
|
639
|
-
- spec/lib/flapjack/gateways/api/contact_methods_spec.rb
|
640
|
-
- spec/lib/flapjack/gateways/api/entity_check_presenter_spec.rb
|
641
|
-
- spec/lib/flapjack/gateways/api/entity_methods_spec.rb
|
642
|
-
- spec/lib/flapjack/gateways/api/entity_presenter_spec.rb
|
643
|
-
- spec/lib/flapjack/gateways/api_spec.rb
|
644
632
|
- spec/lib/flapjack/gateways/email_spec.rb
|
645
633
|
- spec/lib/flapjack/gateways/jabber_spec.rb
|
646
634
|
- spec/lib/flapjack/gateways/jsonapi/check_methods_spec.rb
|
@@ -668,3 +656,5 @@ test_files:
|
|
668
656
|
- spec/spec_helper.rb
|
669
657
|
- spec/support/erb_view_helper.rb
|
670
658
|
- spec/support/jsonapi_helper.rb
|
659
|
+
- spec/support/profile_all_formatter.rb
|
660
|
+
- spec/support/uncolored_doc_formatter.rb
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
1.9.3-p125
|
data/Gemfile-ruby1.9
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
gemspec :name => 'flapjack'
|
4
|
-
|
5
|
-
group :development do
|
6
|
-
gem 'ruby-prof'
|
7
|
-
end
|
8
|
-
|
9
|
-
group :test do
|
10
|
-
gem 'rspec', '~> 3.0.0.beta1'
|
11
|
-
gem 'cucumber'
|
12
|
-
gem 'delorean'
|
13
|
-
gem 'rack-test'
|
14
|
-
gem 'async_rack_test', '>= 0.0.5'
|
15
|
-
gem 'resque_spec'
|
16
|
-
gem 'webmock'
|
17
|
-
gem 'guard'
|
18
|
-
gem 'rb-fsevent'
|
19
|
-
gem 'guard-rspec'
|
20
|
-
gem 'guard-cucumber'
|
21
|
-
gem 'fuubar'
|
22
|
-
gem 'simplecov', :require => false
|
23
|
-
|
24
|
-
if RUBY_VERSION.split('.')[0] == '1' && RUBY_VERSION.split('.')[1] == '9'
|
25
|
-
gem 'debugger-ruby_core_source', '>= 1.3.4' # required for perftools.rb
|
26
|
-
gem 'perftools.rb'
|
27
|
-
end
|
28
|
-
end
|