flapjack 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/.travis.yml +11 -12
  4. data/CHANGELOG.md +10 -0
  5. data/Gemfile +0 -7
  6. data/Rakefile +0 -1
  7. data/bin/flapjack +2 -0
  8. data/etc/flapjack_config.yaml.example +20 -0
  9. data/features/ack_after_sched_maint.feature +1 -1
  10. data/features/cli.feature +1 -1
  11. data/features/notification_rules.feature +1 -1
  12. data/features/notifications.feature +0 -9
  13. data/features/rollup.feature +1 -1
  14. data/features/steps/events_steps.rb +20 -8
  15. data/features/steps/notifications_steps.rb +62 -75
  16. data/features/support/env.rb +17 -8
  17. data/flapjack.gemspec +4 -4
  18. data/lib/flapjack.rb +3 -0
  19. data/lib/flapjack/cli/import.rb +1 -0
  20. data/lib/flapjack/cli/maintenance.rb +1 -0
  21. data/lib/flapjack/cli/purge.rb +2 -0
  22. data/lib/flapjack/cli/receiver.rb +1 -0
  23. data/lib/flapjack/cli/simulate.rb +1 -0
  24. data/lib/flapjack/data/alert.rb +28 -1
  25. data/lib/flapjack/data/contact.rb +1 -1
  26. data/lib/flapjack/data/entity.rb +18 -8
  27. data/lib/flapjack/data/entity_check.rb +17 -0
  28. data/lib/flapjack/data/event.rb +33 -15
  29. data/lib/flapjack/data/migration.rb +46 -23
  30. data/lib/flapjack/filters/delays.rb +13 -6
  31. data/lib/flapjack/gateways/aws_sns.rb +115 -88
  32. data/lib/flapjack/gateways/aws_sns/alert.text.erb +2 -1
  33. data/lib/flapjack/gateways/email.rb +145 -135
  34. data/lib/flapjack/gateways/email/alert.html.erb +6 -4
  35. data/lib/flapjack/gateways/email/alert.text.erb +2 -0
  36. data/lib/flapjack/gateways/jabber.rb +61 -1
  37. data/lib/flapjack/gateways/jabber/alert.text.erb +1 -1
  38. data/lib/flapjack/gateways/pagerduty/alert.text.erb +1 -1
  39. data/lib/flapjack/gateways/sms_gammu.rb +119 -0
  40. data/lib/flapjack/gateways/sms_messagenet.rb +95 -67
  41. data/lib/flapjack/gateways/sms_messagenet/alert.text.erb +2 -1
  42. data/lib/flapjack/gateways/sms_twilio.rb +102 -74
  43. data/lib/flapjack/gateways/sms_twilio/alert.text.erb +2 -1
  44. data/lib/flapjack/logger.rb +1 -1
  45. data/lib/flapjack/notifier.rb +5 -14
  46. data/lib/flapjack/patches.rb +0 -58
  47. data/lib/flapjack/pikelet.rb +8 -78
  48. data/lib/flapjack/processor.rb +3 -1
  49. data/lib/flapjack/redis_pool.rb +2 -0
  50. data/lib/flapjack/version.rb +1 -1
  51. data/spec/lib/flapjack/data/contact_spec.rb +2 -2
  52. data/spec/lib/flapjack/data/entity_spec.rb +15 -0
  53. data/spec/lib/flapjack/data/event_spec.rb +2 -2
  54. data/spec/lib/flapjack/data/migration_spec.rb +11 -0
  55. data/spec/lib/flapjack/gateways/aws_sns_spec.rb +12 -8
  56. data/spec/lib/flapjack/gateways/email_spec.rb +56 -51
  57. data/spec/lib/flapjack/gateways/sms_messagenet_spec.rb +17 -12
  58. data/spec/lib/flapjack/gateways/sms_twilio_spec.rb +17 -12
  59. data/spec/lib/flapjack/pikelet_spec.rb +9 -23
  60. data/spec/lib/flapjack/redis_pool_spec.rb +1 -0
  61. data/tasks/profile.rake +25 -109
  62. metadata +37 -39
  63. data/Gemfile-ruby1.9 +0 -30
  64. data/Gemfile-ruby1.9.lock +0 -250
  65. data/tasks/benchmarks.rake +0 -237
data/Gemfile-ruby1.9.lock DELETED
@@ -1,250 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- flapjack (1.2.1)
5
- activesupport (~> 3.2.14)
6
- blather (~> 0.8.3)
7
- chronic
8
- chronic_duration
9
- dante (= 0.2.0)
10
- em-http-request
11
- em-resque
12
- em-synchrony (~> 1.0.2)
13
- eventmachine (~> 1.0.0)
14
- gli (= 2.12.0)
15
- hiredis
16
- ice_cube
17
- mail
18
- nokogiri (= 1.6.2.1)
19
- oj (>= 2.9.0)
20
- rack-fiber_pool
21
- rake
22
- rbtrace
23
- redis (~> 3.0.6)
24
- resque (~> 1.23.0)
25
- sinatra
26
- terminal-table
27
- thin (~> 1.6.1)
28
- tzinfo (~> 1.0.1)
29
- tzinfo-data
30
-
31
- GEM
32
- remote: https://rubygems.org/
33
- specs:
34
- activesupport (3.2.20)
35
- i18n (~> 0.6, >= 0.6.4)
36
- multi_json (~> 1.0)
37
- addressable (2.3.6)
38
- async_rack_test (0.0.5)
39
- awesome_print (1.2.0)
40
- blather (0.8.8)
41
- activesupport (>= 2.3.11)
42
- eventmachine (>= 1.0.0)
43
- girl_friday
44
- niceogiri (~> 1.0)
45
- nokogiri (~> 1.5, >= 1.5.6)
46
- builder (3.2.2)
47
- celluloid (0.16.0)
48
- timers (~> 4.0.0)
49
- chronic (0.10.2)
50
- chronic_duration (0.10.6)
51
- numerizer (~> 0.1.1)
52
- coderay (1.1.0)
53
- connection_pool (1.2.0)
54
- cookiejar (0.3.2)
55
- crack (0.4.2)
56
- safe_yaml (~> 1.0.0)
57
- cucumber (2.0.0.beta.3)
58
- builder (>= 2.1.2)
59
- cucumber-core (~> 1.0.0.beta.3)
60
- diff-lcs (>= 1.1.3)
61
- gherkin (~> 2.12)
62
- multi_json (>= 1.7.5, < 2.0)
63
- multi_test (>= 0.1.1)
64
- cucumber-core (1.0.0.beta.3)
65
- gherkin (~> 2.12.0)
66
- daemons (1.1.9)
67
- dante (0.2.0)
68
- delorean (2.1.0)
69
- chronic
70
- diff-lcs (1.2.5)
71
- docile (1.1.5)
72
- em-hiredis (0.1.1)
73
- hiredis (~> 0.4.0)
74
- em-http-request (1.1.2)
75
- addressable (>= 2.3.4)
76
- cookiejar
77
- em-socksify (>= 0.3)
78
- eventmachine (>= 1.0.3)
79
- http_parser.rb (>= 0.6.0)
80
- em-resque (1.1.1)
81
- em-hiredis (~> 0.1.0)
82
- em-synchrony (~> 1.0.0)
83
- resque (~> 1.2)
84
- em-socksify (0.3.0)
85
- eventmachine (>= 1.0.0.beta.4)
86
- em-synchrony (1.0.3)
87
- eventmachine (>= 1.0.0.beta.1)
88
- eventmachine (1.0.3)
89
- ffi (1.9.3)
90
- find_a_port (1.0.1)
91
- formatador (0.2.5)
92
- fuubar (2.0.0)
93
- rspec (~> 3.0)
94
- ruby-progressbar (~> 1.4)
95
- gherkin (2.12.2)
96
- multi_json (~> 1.3)
97
- girl_friday (0.11.2)
98
- connection_pool (~> 1.0)
99
- rubinius-actor
100
- gli (2.12.0)
101
- guard (2.6.1)
102
- formatador (>= 0.2.4)
103
- listen (~> 2.7)
104
- lumberjack (~> 1.0)
105
- pry (>= 0.9.12)
106
- thor (>= 0.18.1)
107
- guard-cucumber (1.4.1)
108
- cucumber (>= 1.2.0)
109
- guard (>= 1.1.0)
110
- guard-rspec (4.3.1)
111
- guard (~> 2.1)
112
- rspec (>= 2.14, < 4.0)
113
- hiredis (0.4.5)
114
- hitimes (1.2.2)
115
- http_parser.rb (0.6.0)
116
- i18n (0.6.11)
117
- ice_cube (0.12.1)
118
- json (1.8.1)
119
- listen (2.7.9)
120
- celluloid (>= 0.15.2)
121
- rb-fsevent (>= 0.9.3)
122
- rb-inotify (>= 0.9)
123
- lumberjack (1.0.9)
124
- mail (2.6.3)
125
- mime-types (>= 1.16, < 3)
126
- method_source (0.8.2)
127
- mime-types (2.4.3)
128
- mini_portile (0.6.0)
129
- msgpack (0.5.9)
130
- multi_json (1.10.1)
131
- multi_test (0.1.1)
132
- niceogiri (1.1.2)
133
- nokogiri (~> 1.5)
134
- nokogiri (1.6.2.1)
135
- mini_portile (= 0.6.0)
136
- numerizer (0.1.1)
137
- oj (2.11.0)
138
- pact (1.3.3)
139
- awesome_print (~> 1.1)
140
- find_a_port (~> 1.0.1)
141
- json
142
- rack-test (~> 0.6.2)
143
- randexp (~> 0.1.7)
144
- rspec (>= 2.14)
145
- term-ansicolor (~> 1.0)
146
- thor
147
- webrick
148
- pry (0.10.1)
149
- coderay (~> 1.1.0)
150
- method_source (~> 0.8.1)
151
- slop (~> 3.4)
152
- rack (1.5.2)
153
- rack-fiber_pool (0.9.3)
154
- rack-protection (1.5.3)
155
- rack
156
- rack-test (0.6.2)
157
- rack (>= 1.0)
158
- rake (10.3.2)
159
- randexp (0.1.7)
160
- rb-fsevent (0.9.4)
161
- rb-inotify (0.9.5)
162
- ffi (>= 0.5.0)
163
- rbtrace (0.4.5)
164
- ffi (>= 1.0.6)
165
- msgpack (>= 0.4.3)
166
- trollop (>= 1.16.2)
167
- redis (3.0.7)
168
- redis-namespace (1.5.1)
169
- redis (~> 3.0, >= 3.0.4)
170
- resque (1.23.1)
171
- multi_json (~> 1.0)
172
- redis-namespace (~> 1.0)
173
- sinatra (>= 0.9.2)
174
- vegas (~> 0.1.2)
175
- resque_spec (0.16.0)
176
- resque (>= 1.19.0)
177
- rspec-core (>= 3.0.0)
178
- rspec-expectations (>= 3.0.0)
179
- rspec-mocks (>= 3.0.0)
180
- rspec (3.1.0)
181
- rspec-core (~> 3.1.0)
182
- rspec-expectations (~> 3.1.0)
183
- rspec-mocks (~> 3.1.0)
184
- rspec-core (3.1.4)
185
- rspec-support (~> 3.1.0)
186
- rspec-expectations (3.1.1)
187
- diff-lcs (>= 1.2.0, < 2.0)
188
- rspec-support (~> 3.1.0)
189
- rspec-mocks (3.1.1)
190
- rspec-support (~> 3.1.0)
191
- rspec-support (3.1.0)
192
- rubinius-actor (0.0.2)
193
- rubinius-core-api
194
- rubinius-core-api (0.0.1)
195
- ruby-prof (0.15.1)
196
- ruby-progressbar (1.6.0)
197
- safe_yaml (1.0.3)
198
- simplecov (0.9.1)
199
- docile (~> 1.1.0)
200
- multi_json (~> 1.0)
201
- simplecov-html (~> 0.8.0)
202
- simplecov-html (0.8.0)
203
- sinatra (1.4.5)
204
- rack (~> 1.4)
205
- rack-protection (~> 1.4)
206
- tilt (~> 1.3, >= 1.3.4)
207
- slop (3.6.0)
208
- term-ansicolor (1.3.0)
209
- tins (~> 1.0)
210
- terminal-table (1.4.5)
211
- thin (1.6.3)
212
- daemons (~> 1.0, >= 1.0.9)
213
- eventmachine (~> 1.0)
214
- rack (~> 1.0)
215
- thor (0.19.1)
216
- tilt (1.4.1)
217
- timers (4.0.1)
218
- hitimes
219
- tins (1.3.3)
220
- trollop (2.0)
221
- tzinfo (1.0.1)
222
- tzinfo-data (1.2014.9)
223
- tzinfo (>= 1.0.0)
224
- vegas (0.1.11)
225
- rack (>= 1.0.0)
226
- webmock (1.18.0)
227
- addressable (>= 2.3.6)
228
- crack (>= 0.3.2)
229
- webrick (1.3.1)
230
-
231
- PLATFORMS
232
- ruby
233
-
234
- DEPENDENCIES
235
- async_rack_test (>= 0.0.5)
236
- cucumber (>= 2.0.0.beta.3)
237
- delorean
238
- flapjack!
239
- fuubar
240
- guard
241
- guard-cucumber
242
- guard-rspec
243
- pact
244
- rack-test
245
- rb-fsevent
246
- resque_spec
247
- rspec (~> 3.0)
248
- ruby-prof
249
- simplecov
250
- webmock
@@ -1,237 +0,0 @@
1
- require 'redis'
2
- require 'time'
3
-
4
- # add lib to the default include path
5
- unless $:.include?(File.dirname(__FILE__) + '/../lib/')
6
- $: << File.dirname(__FILE__) + '/../lib'
7
- end
8
-
9
- require 'flapjack/configuration'
10
- require 'flapjack/data/event'
11
- require 'flapjack/data/entity_check'
12
- require 'flapjack/version'
13
-
14
- namespace :benchmarks do
15
-
16
- def redis
17
- @redis ||= Redis.new(@redis_config)
18
- end
19
-
20
- task :setup do
21
- FLAPJACK_ENV = 'test'
22
- config_file = File.join('tasks', 'support', 'flapjack_config_benchmark.yaml')
23
-
24
- config = Flapjack::Configuration.new
25
- config.load( config_file )
26
-
27
- @config_env = config.all
28
- @redis_config = config.for_redis
29
-
30
- if @config_env.nil? || @config_env.empty?
31
- puts "No config data for environment '#{FLAPJACK_ENV}' found in '#{config_file}'"
32
- exit(false)
33
- end
34
- end
35
-
36
- desc "nukes the redis db, generates the events, runs and shuts down flapjack, generates perftools reports"
37
- task :run => [:setup, :reset_redis, :benchmark, :run_flapjack, :reports] do
38
- puts Flapjack.dump_json(@benchmark_data, :indent => 2)
39
- end
40
-
41
- desc "reset the redis database"
42
- task :reset_redis do
43
- raise "I'm not going to let you reset your production redis db, sorry about that." if FLAPJACK_ENV.downcase == "production"
44
- puts "db size before: #{redis.dbsize}"
45
- redis.flushdb
46
- puts "db size after: #{redis.dbsize}"
47
- end
48
-
49
- desc "starts flapjack"
50
- task :run_flapjack do
51
- puts "Discovering path to perftools"
52
- perftools = `gem which perftools | tail -1`
53
- if system("if [ ! -d 'artifacts' ] ; then mkdir artifacts ; fi")
54
- puts "we now have an artifacts dir"
55
- else
56
- raise "Problem creating artifacts: #{$?}"
57
- end
58
- time_flapjack_start = Time.now.to_f
59
- puts "Starting flapjack..."
60
- result = system({"FLAPJACK_ENV" => FLAPJACK_ENV,
61
- "CPUPROFILE" => "artifacts/flapjack-perftools-cpuprofile",
62
- "RUBYOPT" => "-r#{perftools}"},
63
- "bin/flapjack start --no-daemonize --config tasks/support/flapjack_config_benchmark.yaml")
64
- status = $?
65
- if status.exited? && (Signal.list['INT'] + 128).eql?($?.exitstatus)
66
- puts "Flapjack run completed successfully"
67
- else
68
- raise "Problem starting flapjack: #{$?}"
69
- end
70
- @timer_flapjack = Time.now.to_f - time_flapjack_start
71
- end
72
-
73
- desc "generates perftools reports"
74
- task :reports do
75
- @benchmark_data = { 'events_created' => @events_created,
76
- 'flapjack_runtime' => @timer_flapjack,
77
- 'processing_rate' => @events_created.to_f / @timer_flapjack }.merge(@benchmark_parameters)
78
- bytes_written = IO.write('artifacts/benchmark_data.json', Flapjack.dump_json(@benchmark_data, :indent => 2))
79
- puts "benchmark data written to artifacts/benchmark_data.json (#{bytes_written} bytes)"
80
-
81
- if system("pprof.rb --text artifacts/flapjack-perftools-cpuprofile > artifacts/flapjack-perftools-cpuprofile.txt")
82
- puts "Generated perftools.rb text report at artifacts/flapjack-perftools-cpuprofile.txt"
83
- system("head -24 artifacts/flapjack-perftools-cpuprofile.txt")
84
- else
85
- raise "Problem generating perftools.rb text report: #{$?}"
86
- end
87
- if system("pprof.rb --pdf artifacts/flapjack-perftools-cpuprofile > artifacts/flapjack-perftools-cpuprofile.pdf")
88
- puts "Generated perftools.rb pdf report at artifacts/flapjack-perftools-cpuprofile.pdf"
89
- else
90
- raise "Problem generating perftools.rb pdf report: #{$?}"
91
- end
92
- end
93
-
94
-
95
- desc "run benchmark - simulate a stream of events from the check execution system"
96
- # Assumptions:
97
- # - time to failure varies evenly between 1 hour and 1 month
98
- # - time to recovery varies evenly between 10 seconds and 1 week
99
- task :benchmark do
100
- unless RUBY_VERSION.split('.')[0] == '1' && RUBY_VERSION.split('.')[1] == '9'
101
- # Flapjack doesn't support 1.8 or below, so just checking for 1.9 is OK
102
- raise "perftools.rb doesn't work on Ruby 2.0 or greater"
103
- end
104
-
105
- num_checks_per_entity = (ENV['CHECKS_PER_ENTITY'] || 5).to_i
106
- num_entities = (ENV['ENTITIES'] || 100).to_i
107
- interval = (ENV['INTERVAL'] || 60).to_i
108
- hours = (ENV['HOURS'] || 1).to_f
109
- seed = (ENV['SEED'] || 42).to_i
110
-
111
- puts "Behaviour can be modified by setting any combination of the following environment variables: "
112
- puts "CHECKS_PER_ENTITY - #{num_checks_per_entity}"
113
- puts "ENTITIES - #{num_entities}"
114
- puts "INTERVAL - #{interval}"
115
- puts "HOURS - #{hours}"
116
- puts "SEED - #{seed}"
117
- puts "FLAPJACK_ENV - #{FLAPJACK_ENV}"
118
-
119
- raise "INTERVAL must be less than (or equal to) 3600 seconds (1 hour)" unless interval <= 3600
120
-
121
- cycles_per_hour = (60.0 * 60) / interval
122
- cycles_per_day = (60.0 * 60 * 24) / interval
123
- cycles_per_week = (60.0 * 60 * 24 * 7) / interval
124
- cycles_per_month = (60.0 * 60 * 24 * 7 * 30) / interval
125
- cycles = (hours * cycles_per_hour).to_i
126
- failure_prob_min = 1.0 / cycles_per_month
127
- failure_prob_max = 1.0 / cycles_per_hour
128
- recovery_prob_min = 1.0 / cycles_per_week
129
- recovery_prob_max = 1.0
130
- initial_ok_prob = 1
131
- num_checks = num_checks_per_entity * num_entities
132
-
133
- prng = Random.new(seed)
134
-
135
- ok = 0
136
- critical = 0
137
- check_id = 1
138
- entities = (1..num_entities).to_a.inject({}) {|memo, id|
139
- checks = (1..num_checks_per_entity).to_a.inject({}) {|memo_check, id_check|
140
- memo_check[check_id] = {:name => "Check Type #{id_check}",
141
- :state => ( prng.rand < initial_ok_prob ? 'OK' : 'CRITICAL' ),
142
- :p_failure => prng.rand(failure_prob_min..failure_prob_max),
143
- :p_recovery => prng.rand(recovery_prob_min..recovery_prob_max)}
144
- ok += 1 if memo_check[check_id][:state] == 'OK'
145
- critical += 1 if memo_check[check_id][:state] == 'CRITICAL'
146
- check_id += 1
147
- memo_check
148
- }
149
- memo[id] = checks
150
- memo
151
- }
152
- #puts "ok: #{ok * 100.0 / num_checks}% (#{ok}), critical: #{100.0 * critical / num_checks}% (#{critical})"
153
-
154
- events_created = 0
155
- ok_to_critical = 0
156
- critical_to_ok = 0
157
- ok_events = 0
158
- critical_events = 0
159
- state_changes = 0
160
- (0..cycles).to_a.each {|i|
161
- changes = 0
162
- ok = 0
163
- critical = 0
164
- summary = "You tell me summer's here \nand the time is wrong \n"
165
- summary << "You tell me winter's here \nAnd your days are getting long"
166
- entities.each_pair {|entity_id, checks|
167
- checks.each_pair {|check_id, check|
168
- changed = false
169
- previous_state = check[:state]
170
- case previous_state
171
- when "OK"
172
- if prng.rand < check[:p_failure]
173
- check[:state] = "CRITICAL"
174
- changed = true
175
- changes += 1
176
- ok_to_critical += 1
177
- end
178
- when "CRITICAL"
179
- if prng.rand < check[:p_recovery]
180
- check[:state] = "OK"
181
- changed = true
182
- changes += 1
183
- critical_to_ok += 1
184
- end
185
- end
186
- ok += 1 if check[:state] == 'OK'
187
- critical += 1 if check[:state] == 'CRITICAL'
188
-
189
- Flapjack::Data::Event.add({'entity' => "entity_#{entity_id}.example.com",
190
- 'check' => check[:name],
191
- 'type' => 'service',
192
- 'state' => check[:state],
193
- 'summary' => summary }, :redis => redis)
194
- events_created += 1
195
- }
196
- }
197
- ok_events += ok
198
- critical_events += critical
199
- state_changes += changes
200
-
201
- #puts "ok: #{100.0 * ok / num_checks}% (#{ok}), critical: #{100.0 * critical / num_checks}% (#{critical}), changed: #{100.0 * changes / num_checks}% (#{changes})"
202
-
203
- }
204
- puts "created #{events_created} events:"
205
- puts " OK: #{ok_events} (#{ (100.0 * ok_events / events_created).round(1)}%)"
206
- puts " CRITICAL: #{critical_events} (#{ (100.0 * critical_events / events_created).round(1)}%)"
207
- puts "containing #{state_changes} state changes (#{ (100.0 * state_changes / events_created).round(1)}%):"
208
- puts " OK -> CRITICAL: #{ok_to_critical} (#{ (100.0 * ok_to_critical / events_created).round(1)}%)"
209
- puts " CRITICAL -> OK: #{critical_to_ok} (#{ (100.0 * critical_to_ok / events_created).round(1)}%)"
210
-
211
- @events_created = events_created
212
- @benchmark_parameters = { 'events_created' => events_created,
213
- 'ok_to_critical' => ok_to_critical,
214
- 'critical_to_ok' => critical_to_ok,
215
- 'checks_per_entity' => num_checks_per_entity,
216
- 'entities' => num_entities,
217
- 'interval' => interval,
218
- 'hours' => hours,
219
- 'cycles' => cycles,
220
- 'failure_prob_min' => failure_prob_min,
221
- 'failure_prob_max' => failure_prob_max,
222
- 'recovery_prob_min' => recovery_prob_min,
223
- 'recovery_prob_max' => recovery_prob_max,
224
- 'initial_ok_prob' => initial_ok_prob,
225
- 'seed' => seed,
226
- 'flapjack_env' => FLAPJACK_ENV,
227
- 'version' => Flapjack::VERSION,
228
- 'git_last_commit' => `git rev-parse HEAD`.chomp,
229
- 'git_version' => `git describe --long --dirty --abbrev=10 --tags`.chomp,
230
- 'git_branch' => `git status --porcelain -b | head -1 | cut -d ' ' -f 2`.chomp,
231
- 'ruby_build' => `ruby --version`.chomp,
232
- 'time' => Time.new.iso8601,
233
- 'hostname' => `hostname -f`.chomp,
234
- 'uname' => `uname -a`.chomp }
235
- end
236
-
237
- end