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
@@ -1,211 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'flapjack/gateways/api/entity_check_presenter'
|
3
|
-
|
4
|
-
describe 'Flapjack::Gateways::API::EntityCheckPresenter' do
|
5
|
-
|
6
|
-
let(:entity_check) { double(Flapjack::Data::EntityCheck) }
|
7
|
-
|
8
|
-
let(:time) { Time.now.to_i }
|
9
|
-
|
10
|
-
let(:states) {
|
11
|
-
[{:state => 'critical', :timestamp => time - (4 * 60 * 60)},
|
12
|
-
{:state => 'ok', :timestamp => time - (4 * 60 * 60) + (5 * 60)},
|
13
|
-
{:state => 'critical', :timestamp => time - (3 * 60 * 60)},
|
14
|
-
{:state => 'ok', :timestamp => time - (3 * 60 * 60) + (10 * 60)},
|
15
|
-
{:state => 'critical', :timestamp => time - (2 * 60 * 60)},
|
16
|
-
{:state => 'ok', :timestamp => time - (2 * 60 * 60) + (15 * 60)},
|
17
|
-
{:state => 'critical', :timestamp => time - (1 * 60 * 60)},
|
18
|
-
{:state => 'ok', :timestamp => time - (1 * 60 * 60) + (20 * 60)}
|
19
|
-
]
|
20
|
-
}
|
21
|
-
|
22
|
-
# one overlap at start, one overlap at end, one wholly overlapping,
|
23
|
-
# one wholly contained
|
24
|
-
let(:maintenances) {
|
25
|
-
[{:start_time => time - ((4 * 60 * 60) + (1 * 60)), # 1 minute before outage starts
|
26
|
-
:end_time => time - (4 * 60 * 60) + (2 * 60), # 2 minutes after outage starts
|
27
|
-
:duration => (3 * 60)},
|
28
|
-
{:start_time => time - (3 * 60 * 60) + (8 * 60), # 2 minutes before outage ends
|
29
|
-
:end_time => time - (3 * 60 * 60) + (11 * 60), # 1 minute after outage ends
|
30
|
-
:duration => (3 * 60)},
|
31
|
-
{:start_time => time - ((2 * 60 * 60) + (1 * 60)), # 1 minute before outage starts
|
32
|
-
:end_time => time - (2 * 60 * 60) + (17 * 60), # 2 minutes after outage ends
|
33
|
-
:duration => (3 * 60)},
|
34
|
-
{:start_time => time - (1 * 60 * 60) + (1 * 60), # 1 minute after outage starts
|
35
|
-
:end_time => time - (1 * 60 * 60) + (10 * 60), # 10 minutes before outage ends
|
36
|
-
:duration => (9 * 60)}
|
37
|
-
]
|
38
|
-
}
|
39
|
-
|
40
|
-
it "returns a list of outage hashes for an entity check" do
|
41
|
-
expect(entity_check).to receive(:historical_states).
|
42
|
-
with(time - (5 * 60 * 60), time - (2 * 60 * 60)).and_return(states)
|
43
|
-
|
44
|
-
expect(entity_check).to receive(:historical_state_before).
|
45
|
-
with(time - (4 * 60 * 60)).and_return(nil)
|
46
|
-
|
47
|
-
ecp = Flapjack::Gateways::API::EntityCheckPresenter.new(entity_check)
|
48
|
-
outages = ecp.outages(time - (5 * 60 * 60), time - (2 * 60 * 60))
|
49
|
-
expect(outages).not_to be_nil
|
50
|
-
expect(outages).to be_an(Array)
|
51
|
-
expect(outages.size).to eq(4)
|
52
|
-
|
53
|
-
# TODO check the data in those hashes
|
54
|
-
end
|
55
|
-
|
56
|
-
it "returns a list of outage hashes with no start and end time set" do
|
57
|
-
expect(entity_check).to receive(:historical_states).
|
58
|
-
with(nil, nil).and_return(states)
|
59
|
-
|
60
|
-
expect(entity_check).to receive(:historical_state_before).
|
61
|
-
with(time - (4 * 60 * 60)).and_return(nil)
|
62
|
-
|
63
|
-
ecp = Flapjack::Gateways::API::EntityCheckPresenter.new(entity_check)
|
64
|
-
outages = ecp.outages(nil, nil)
|
65
|
-
expect(outages).not_to be_nil
|
66
|
-
expect(outages).to be_an(Array)
|
67
|
-
expect(outages.size).to eq(4)
|
68
|
-
|
69
|
-
# TODO check the data in those hashes
|
70
|
-
end
|
71
|
-
|
72
|
-
it "returns a consolidated list of outage hashes with repeated state events" do
|
73
|
-
states[1][:state] = 'critical'
|
74
|
-
states[2][:state] = 'ok'
|
75
|
-
|
76
|
-
expect(entity_check).to receive(:historical_states).
|
77
|
-
with(nil, nil).and_return(states)
|
78
|
-
|
79
|
-
expect(entity_check).to receive(:historical_state_before).
|
80
|
-
with(time - (4 * 60 * 60)).and_return(nil)
|
81
|
-
|
82
|
-
ecp = Flapjack::Gateways::API::EntityCheckPresenter.new(entity_check)
|
83
|
-
outages = ecp.outages(nil, nil)
|
84
|
-
expect(outages).not_to be_nil
|
85
|
-
expect(outages).to be_an(Array)
|
86
|
-
expect(outages.size).to eq(3)
|
87
|
-
end
|
88
|
-
|
89
|
-
it "returns a (small) outage hash for a single state change" do
|
90
|
-
expect(entity_check).to receive(:historical_states).
|
91
|
-
with(nil, nil).and_return([{:state => 'critical', :timestamp => time - (4 * 60 * 60)}])
|
92
|
-
expect(entity_check).to receive(:historical_state_before).
|
93
|
-
with(time - (4 * 60 * 60)).and_return(nil)
|
94
|
-
|
95
|
-
ecp = Flapjack::Gateways::API::EntityCheckPresenter.new(entity_check)
|
96
|
-
outages = ecp.outages(nil, nil)
|
97
|
-
expect(outages).not_to be_nil
|
98
|
-
expect(outages).to be_an(Array)
|
99
|
-
expect(outages.size).to eq(1)
|
100
|
-
end
|
101
|
-
|
102
|
-
it "a list of unscheduled maintenances for an entity check" do
|
103
|
-
expect(entity_check).to receive(:maintenances).
|
104
|
-
with(time - (12 * 60 * 60), time, :scheduled => false).and_return(maintenances)
|
105
|
-
|
106
|
-
expect(entity_check).to receive(:maintenances).
|
107
|
-
with(nil, time - (12 * 60 * 60), :scheduled => false).and_return([])
|
108
|
-
|
109
|
-
ecp = Flapjack::Gateways::API::EntityCheckPresenter.new(entity_check)
|
110
|
-
unsched_maint = ecp.unscheduled_maintenances(time - (12 * 60 * 60), time)
|
111
|
-
|
112
|
-
expect(unsched_maint).to be_an(Array)
|
113
|
-
expect(unsched_maint.size).to eq(4)
|
114
|
-
|
115
|
-
# TODO check the data in those hashes
|
116
|
-
end
|
117
|
-
|
118
|
-
it "a list of scheduled maintenances for an entity check" do
|
119
|
-
expect(entity_check).to receive(:maintenances).
|
120
|
-
with(time - (12 * 60 * 60), time, :scheduled => true).and_return(maintenances)
|
121
|
-
|
122
|
-
expect(entity_check).to receive(:maintenances).
|
123
|
-
with(nil, time - (12 * 60 * 60), :scheduled => true).and_return([])
|
124
|
-
|
125
|
-
ecp = Flapjack::Gateways::API::EntityCheckPresenter.new(entity_check)
|
126
|
-
sched_maint = ecp.scheduled_maintenances(time - (12 * 60 * 60), time)
|
127
|
-
|
128
|
-
expect(sched_maint).to be_an(Array)
|
129
|
-
expect(sched_maint.size).to eq(4)
|
130
|
-
|
131
|
-
# TODO check the data in those hashes
|
132
|
-
end
|
133
|
-
|
134
|
-
it "returns downtime and percentage for a downtime check" do
|
135
|
-
expect(entity_check).to receive(:historical_states).
|
136
|
-
with(time - (12 * 60 * 60), time).and_return(states)
|
137
|
-
|
138
|
-
expect(entity_check).to receive(:historical_state_before).
|
139
|
-
with(time - (4 * 60 * 60)).and_return(nil)
|
140
|
-
|
141
|
-
expect(entity_check).to receive(:maintenances).
|
142
|
-
with(time - (12 * 60 * 60), time, :scheduled => true).and_return(maintenances)
|
143
|
-
|
144
|
-
expect(entity_check).to receive(:maintenances).
|
145
|
-
with(nil, time - (12 * 60 * 60), :scheduled => true).and_return([])
|
146
|
-
|
147
|
-
ecp = Flapjack::Gateways::API::EntityCheckPresenter.new(entity_check)
|
148
|
-
downtimes = ecp.downtime(time - (12 * 60 * 60), time)
|
149
|
-
|
150
|
-
# 22 minutes, 3 + 8 + 11
|
151
|
-
expect(downtimes).to be_a(Hash)
|
152
|
-
expect(downtimes[:total_seconds]).to eq({'critical' => (22 * 60),
|
153
|
-
'ok' => ((12 * 60 * 60) - (22 * 60))})
|
154
|
-
expect(downtimes[:percentages]).to eq({'critical' => (((22 * 60) * 100.0) / (12 * 60 * 60)),
|
155
|
-
'ok' => ((((12 * 60 * 60) - (22 * 60)) * 100.0) / (12 * 60 *60))})
|
156
|
-
expect(downtimes[:downtime]).to be_an(Array)
|
157
|
-
# the last outage gets split by the intervening maintenance period,
|
158
|
-
# but the fully covered one gets removed.
|
159
|
-
expect(downtimes[:downtime].size).to eq(4)
|
160
|
-
end
|
161
|
-
|
162
|
-
it "returns downtime (but no percentage) for an unbounded downtime check" do
|
163
|
-
expect(entity_check).to receive(:historical_states).
|
164
|
-
with(nil, nil).and_return(states)
|
165
|
-
|
166
|
-
expect(entity_check).to receive(:historical_state_before).
|
167
|
-
with(time - (4 * 60 * 60)).and_return(nil)
|
168
|
-
|
169
|
-
expect(entity_check).to receive(:maintenances).
|
170
|
-
with(nil, nil, :scheduled => true).and_return(maintenances)
|
171
|
-
|
172
|
-
ecp = Flapjack::Gateways::API::EntityCheckPresenter.new(entity_check)
|
173
|
-
downtimes = ecp.downtime(nil, nil)
|
174
|
-
|
175
|
-
# 22 minutes, 3 + 8 + 11
|
176
|
-
expect(downtimes).to be_a(Hash)
|
177
|
-
expect(downtimes[:total_seconds]).to eq({'critical' => (22 * 60)})
|
178
|
-
expect(downtimes[:percentages]).to eq({'critical' => nil})
|
179
|
-
expect(downtimes[:downtime]).to be_an(Array)
|
180
|
-
# the last outage gets split by the intervening maintenance period,
|
181
|
-
# but the fully covered one gets removed.
|
182
|
-
expect(downtimes[:downtime].size).to eq(4)
|
183
|
-
end
|
184
|
-
|
185
|
-
it "returns downtime and handles an unfinished problem state" do
|
186
|
-
current = [{:state => 'critical', :timestamp => time - (4 * 60 * 60)},
|
187
|
-
{:state => 'ok', :timestamp => time - (4 * 60 * 60) + (5 * 60)},
|
188
|
-
{:state => 'critical', :timestamp => time - (3 * 60 * 60)}]
|
189
|
-
|
190
|
-
expect(entity_check).to receive(:historical_states).
|
191
|
-
with(nil, nil).and_return(current)
|
192
|
-
|
193
|
-
expect(entity_check).to receive(:historical_state_before).
|
194
|
-
with(time - (4 * 60 * 60)).and_return(nil)
|
195
|
-
|
196
|
-
expect(entity_check).to receive(:maintenances).
|
197
|
-
with(nil, nil, :scheduled => true).and_return([])
|
198
|
-
|
199
|
-
ecp = Flapjack::Gateways::API::EntityCheckPresenter.new(entity_check)
|
200
|
-
downtimes = ecp.downtime(nil, nil)
|
201
|
-
|
202
|
-
expect(downtimes).to be_a(Hash)
|
203
|
-
expect(downtimes[:total_seconds]).to eq({'critical' => (5 * 60)})
|
204
|
-
expect(downtimes[:percentages]).to eq({'critical' => nil})
|
205
|
-
expect(downtimes[:downtime]).to be_an(Array)
|
206
|
-
# the last outage gets split by the intervening maintenance period,
|
207
|
-
# but the fully covered one gets removed.
|
208
|
-
expect(downtimes[:downtime].size).to eq(2)
|
209
|
-
end
|
210
|
-
|
211
|
-
end
|