flapjack 0.7.14 → 0.7.15
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +10 -0
- data/etc/flapjack_config.yaml.example +1 -0
- data/features/events.feature +5 -0
- data/features/notification_rules.feature +1 -1
- data/features/steps/events_steps.rb +28 -13
- data/features/steps/notifications_steps.rb +1 -1
- data/lib/flapjack/coordinator.rb +3 -1
- data/lib/flapjack/data/contact.rb +8 -6
- data/lib/flapjack/data/entity_check.rb +78 -113
- data/lib/flapjack/data/event.rb +54 -65
- data/lib/flapjack/data/notification.rb +5 -1
- data/lib/flapjack/executive.rb +42 -38
- data/lib/flapjack/filters/acknowledgement.rb +5 -5
- data/lib/flapjack/filters/base.rb +2 -2
- data/lib/flapjack/filters/delays.rb +11 -11
- data/lib/flapjack/filters/detect_mass_client_failures.rb +8 -8
- data/lib/flapjack/filters/ok.rb +6 -6
- data/lib/flapjack/filters/scheduled_maintenance.rb +2 -2
- data/lib/flapjack/filters/unscheduled_maintenance.rb +3 -2
- data/lib/flapjack/gateways/api.rb +374 -277
- data/lib/flapjack/gateways/api/entity_check_presenter.rb +52 -21
- data/lib/flapjack/gateways/api/entity_presenter.rb +14 -9
- data/lib/flapjack/gateways/email.rb +7 -0
- data/lib/flapjack/gateways/email/alert.html.haml +13 -1
- data/lib/flapjack/gateways/email/alert.text.erb +5 -4
- data/lib/flapjack/gateways/jabber.rb +90 -34
- data/lib/flapjack/gateways/pagerduty.rb +6 -2
- data/lib/flapjack/gateways/web.rb +13 -8
- data/lib/flapjack/gateways/web/views/check.haml +70 -45
- data/lib/flapjack/gateways/web/views/checks.haml +1 -1
- data/lib/flapjack/gateways/web/views/entity.haml +1 -1
- data/lib/flapjack/patches.rb +9 -2
- data/lib/flapjack/pikelet.rb +14 -10
- data/lib/flapjack/utility.rb +10 -4
- data/lib/flapjack/version.rb +1 -1
- data/spec/lib/flapjack/coordinator_spec.rb +19 -5
- data/spec/lib/flapjack/data/entity_check_spec.rb +3 -30
- data/spec/lib/flapjack/data/event_spec.rb +96 -1
- data/spec/lib/flapjack/executive_spec.rb +5 -11
- data/spec/lib/flapjack/gateways/api/entity_check_presenter_spec.rb +22 -3
- data/spec/lib/flapjack/gateways/api/entity_presenter_spec.rb +30 -15
- data/spec/lib/flapjack/gateways/api_spec.rb +552 -186
- data/spec/lib/flapjack/gateways/email_spec.rb +2 -0
- data/spec/lib/flapjack/gateways/jabber_spec.rb +5 -4
- data/spec/lib/flapjack/gateways/pagerduty_spec.rb +3 -2
- data/spec/lib/flapjack/gateways/web_spec.rb +17 -12
- data/spec/lib/flapjack/pikelet_spec.rb +5 -2
- metadata +4 -5
- data/config.ru +0 -11
@@ -38,6 +38,8 @@ describe Flapjack::Gateways::Email, :logger => true do
|
|
38
38
|
'contact_last_name' => 'Smith',
|
39
39
|
'state' => 'ok',
|
40
40
|
'summary' => 'smile',
|
41
|
+
'last_state' => 'problem',
|
42
|
+
'last_summary' => 'frown',
|
41
43
|
'time' => Time.now.to_i,
|
42
44
|
'event_id' => 'example.com:ping'}
|
43
45
|
|
@@ -63,10 +63,11 @@ describe Flapjack::Gateways::Jabber, :logger => true do
|
|
63
63
|
|
64
64
|
entity_check = mock(Flapjack::Data::EntityCheck)
|
65
65
|
entity_check.should_receive(:in_unscheduled_maintenance?)
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
66
|
+
|
67
|
+
Flapjack::Data::Event.should_receive(:create_acknowledgement).
|
68
|
+
with('main-example.com', 'ping', :summary => 'fixing now',
|
69
|
+
:acknowledgement_id => '876',
|
70
|
+
:duration => (90 * 60), :redis => redis)
|
70
71
|
|
71
72
|
Flapjack::Data::EntityCheck.should_receive(:for_event_id).
|
72
73
|
with('main-example.com:ping', :redis => redis).
|
@@ -105,8 +105,9 @@ describe Flapjack::Gateways::Pagerduty, :logger => true do
|
|
105
105
|
entity_check = mock('entity_check')
|
106
106
|
entity_check.should_receive(:check).and_return('PING')
|
107
107
|
entity_check.should_receive(:contacts).and_return([contact])
|
108
|
-
entity_check.should_receive(:entity_name).exactly(2).times.and_return('foo-app-01.bar.net
|
109
|
-
|
108
|
+
entity_check.should_receive(:entity_name).exactly(2).times.and_return('foo-app-01.bar.net')
|
109
|
+
Flapjack::Data::Event.should_receive(:create_acknowledgement).with('foo-app-01.bar.net', 'PING',
|
110
|
+
:summary => 'Acknowledged on PagerDuty', :redis => redis)
|
110
111
|
|
111
112
|
Flapjack::Data::Global.should_receive(:unacknowledged_failing_checks).and_return([entity_check])
|
112
113
|
|
@@ -56,9 +56,9 @@ describe Flapjack::Gateways::Web, :sinatra => true, :logger => true do
|
|
56
56
|
ec.should_receive(:state).and_return('ok')
|
57
57
|
ec.should_receive(:last_update).and_return(time - (3 * 60 * 60))
|
58
58
|
ec.should_receive(:last_change).and_return(time - (3 * 60 * 60))
|
59
|
-
ec.should_receive(:
|
60
|
-
ec.should_receive(:
|
61
|
-
ec.should_receive(:
|
59
|
+
ec.should_receive(:last_notification_for_state).with(:problem).and_return({:timestamp => time - ((3 * 60 * 60) + (5 * 60))})
|
60
|
+
ec.should_receive(:last_notification_for_state).with(:recovery).and_return({:timestamp => time - (3 * 60 * 60)})
|
61
|
+
ec.should_receive(:last_notification_for_state).with(:acknowledgement).and_return({:timestamp => nil})
|
62
62
|
ec.should_receive(:in_scheduled_maintenance?).and_return(false)
|
63
63
|
ec.should_receive(:in_unscheduled_maintenance?).and_return(false)
|
64
64
|
end
|
@@ -111,16 +111,17 @@ describe Flapjack::Gateways::Web, :sinatra => true, :logger => true do
|
|
111
111
|
end
|
112
112
|
|
113
113
|
it "shows the state of a check for an entity" do
|
114
|
-
time = Time.now
|
114
|
+
time = Time.now
|
115
|
+
Time.should_receive(:now).exactly(4).times.and_return(time)
|
115
116
|
|
116
|
-
last_notifications = {:problem => time - ((3 * 60 * 60) + (5 * 60)),
|
117
|
-
:recovery => time - (3 * 60 * 60),
|
118
|
-
:acknowledgement => nil }
|
117
|
+
last_notifications = {:problem => {:timestamp => time.to_i - ((3 * 60 * 60) + (5 * 60)), :summary => 'prob'},
|
118
|
+
:recovery => {:timestamp => time.to_i - (3 * 60 * 60), :summary => nil},
|
119
|
+
:acknowledgement => {:timestamp => nil, :summary => nil} }
|
119
120
|
|
120
121
|
expect_check_stats
|
121
122
|
entity_check.should_receive(:state).and_return('ok')
|
122
|
-
entity_check.should_receive(:last_update).and_return(time - (3 * 60 * 60))
|
123
|
-
entity_check.should_receive(:last_change).and_return(time - (3 * 60 * 60))
|
123
|
+
entity_check.should_receive(:last_update).and_return(time.to_i - (3 * 60 * 60))
|
124
|
+
entity_check.should_receive(:last_change).and_return(time.to_i - (3 * 60 * 60))
|
124
125
|
entity_check.should_receive(:summary).and_return('all good')
|
125
126
|
entity_check.should_receive(:details).and_return('seriously, all very wonderful')
|
126
127
|
entity_check.should_receive(:last_notifications_of_each_type).and_return(last_notifications)
|
@@ -130,6 +131,9 @@ describe Flapjack::Gateways::Web, :sinatra => true, :logger => true do
|
|
130
131
|
entity_check.should_receive(:current_maintenance).with(:scheduled => false).and_return(false)
|
131
132
|
entity_check.should_receive(:contacts).and_return([])
|
132
133
|
|
134
|
+
entity_check.should_receive(:historical_states).
|
135
|
+
with(nil, time.to_i, :order => 'desc', :limit => 20).and_return([])
|
136
|
+
|
133
137
|
Flapjack::Data::Entity.should_receive(:find_by_name).
|
134
138
|
with(entity_name, :redis => redis).and_return(entity)
|
135
139
|
|
@@ -165,10 +169,11 @@ describe Flapjack::Gateways::Web, :sinatra => true, :logger => true do
|
|
165
169
|
Flapjack::Data::EntityCheck.should_receive(:for_entity).
|
166
170
|
with(entity, 'ping', :redis => redis).and_return(entity_check)
|
167
171
|
|
168
|
-
|
169
|
-
with(
|
172
|
+
Flapjack::Data::Event.should_receive(:create_acknowledgement).
|
173
|
+
with(entity_name, 'ping', :summary => "", :duration => (4 * 60 * 60),
|
174
|
+
:acknowledgement_id => '1234', :redis => redis)
|
170
175
|
|
171
|
-
post "/acknowledgements/#{entity_name_esc}/ping"
|
176
|
+
post "/acknowledgements/#{entity_name_esc}/ping?acknowledgement_id=1234"
|
172
177
|
last_response.status.should == 302
|
173
178
|
end
|
174
179
|
|
@@ -10,6 +10,8 @@ describe Flapjack::Pikelet do
|
|
10
10
|
|
11
11
|
let(:fiber) { mock(Fiber) }
|
12
12
|
|
13
|
+
let(:time) { Time.now }
|
14
|
+
|
13
15
|
before do
|
14
16
|
Flapjack::Pikelet::Resque.class_variable_set(:@@resque_pool, nil)
|
15
17
|
end
|
@@ -22,13 +24,14 @@ describe Flapjack::Pikelet do
|
|
22
24
|
executive = mock('executive')
|
23
25
|
executive.should_receive(:start)
|
24
26
|
Flapjack::Executive.should_receive(:new).with(:config => config,
|
25
|
-
|
27
|
+
:redis_config => redis_config, :boot_time => time, :logger => logger).
|
28
|
+
and_return(executive)
|
26
29
|
|
27
30
|
fiber.should_receive(:resume)
|
28
31
|
Fiber.should_receive(:new).and_yield.and_return(fiber)
|
29
32
|
|
30
33
|
pik = Flapjack::Pikelet.create('executive', :config => config,
|
31
|
-
:redis_config => redis_config)
|
34
|
+
:redis_config => redis_config, :boot_time => time)
|
32
35
|
pik.should be_a(Flapjack::Pikelet::Generic)
|
33
36
|
pik.start
|
34
37
|
end
|
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.7.
|
4
|
+
version: 0.7.15
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2013-06-
|
14
|
+
date: 2013-06-27 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: dante
|
@@ -398,7 +398,6 @@ files:
|
|
398
398
|
- bin/flapper
|
399
399
|
- bin/receive-events
|
400
400
|
- bin/simulate-failed-check
|
401
|
-
- config.ru
|
402
401
|
- dist/etc/init.d/flapjack
|
403
402
|
- dist/etc/init.d/flapjack-nagios-receiver
|
404
403
|
- dist/etc/init.d/flapper
|
@@ -554,7 +553,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
554
553
|
version: '0'
|
555
554
|
segments:
|
556
555
|
- 0
|
557
|
-
hash:
|
556
|
+
hash: 3712563231395847463
|
558
557
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
559
558
|
none: false
|
560
559
|
requirements:
|
@@ -563,7 +562,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
563
562
|
version: '0'
|
564
563
|
segments:
|
565
564
|
- 0
|
566
|
-
hash:
|
565
|
+
hash: 3712563231395847463
|
567
566
|
requirements: []
|
568
567
|
rubyforge_project:
|
569
568
|
rubygems_version: 1.8.23
|