flapjack 0.6.39 → 0.6.40

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. data/.gitignore +2 -2
  2. data/Gemfile +5 -1
  3. data/README.md +3 -2
  4. data/Rakefile +2 -1
  5. data/bin/flapjack +2 -2
  6. data/bin/flapjack-nagios-receiver +2 -8
  7. data/bin/flapjack-populator +11 -11
  8. data/etc/flapjack_config.yaml.example +28 -0
  9. data/features/steps/events_steps.rb +1 -1
  10. data/features/steps/notifications_steps.rb +7 -4
  11. data/features/support/env.rb +17 -6
  12. data/flapjack.gemspec +1 -0
  13. data/lib/flapjack/api.rb +72 -28
  14. data/lib/flapjack/configuration.rb +9 -1
  15. data/lib/flapjack/coordinator.rb +138 -162
  16. data/lib/flapjack/data/contact.rb +3 -1
  17. data/lib/flapjack/data/entity.rb +10 -1
  18. data/lib/flapjack/data/entity_check.rb +19 -21
  19. data/lib/flapjack/data/event.rb +26 -27
  20. data/lib/flapjack/data/message.rb +45 -0
  21. data/lib/flapjack/data/notification.rb +49 -0
  22. data/lib/flapjack/executive.rb +53 -74
  23. data/lib/flapjack/filters/acknowledgement.rb +14 -11
  24. data/lib/flapjack/jabber.rb +84 -18
  25. data/lib/flapjack/notification/email.rb +67 -37
  26. data/lib/flapjack/notification/sms.rb +40 -28
  27. data/lib/flapjack/oobetet.rb +1 -1
  28. data/lib/flapjack/pagerduty.rb +24 -15
  29. data/lib/flapjack/patches.rb +3 -1
  30. data/lib/flapjack/pikelet.rb +51 -20
  31. data/lib/flapjack/rack_logger.rb +8 -0
  32. data/lib/flapjack/version.rb +1 -1
  33. data/lib/flapjack/web.rb +51 -27
  34. data/spec/lib/flapjack/api_spec.rb +28 -3
  35. data/spec/lib/flapjack/coordinator_spec.rb +69 -43
  36. data/spec/lib/flapjack/data/contact_spec.rb +17 -9
  37. data/spec/lib/flapjack/data/entity_check_spec.rb +0 -25
  38. data/spec/lib/flapjack/data/entity_spec.rb +4 -0
  39. data/spec/lib/flapjack/data/global_spec.rb +6 -0
  40. data/spec/lib/flapjack/data/message_spec.rb +6 -0
  41. data/spec/lib/flapjack/data/notification_spec.rb +6 -0
  42. data/spec/lib/flapjack/executive_spec.rb +2 -2
  43. data/spec/lib/flapjack/jabber_spec.rb +8 -9
  44. data/spec/lib/flapjack/pagerduty_spec.rb +53 -45
  45. data/spec/lib/flapjack/utility_spec.rb +55 -0
  46. data/spec/lib/flapjack/web_spec.rb +7 -5
  47. data/tasks/events.rake +26 -59
  48. data/tasks/profile.rake +366 -0
  49. metadata +30 -19
  50. data/lib/flapjack/notification/common.rb +0 -23
  51. data/lib/flapjack/persistence/couch.rb +0 -5
  52. data/lib/flapjack/persistence/couch/connection.rb +0 -66
  53. data/lib/flapjack/persistence/couch/couch.rb +0 -63
  54. data/lib/flapjack/persistence/data_mapper.rb +0 -3
  55. data/lib/flapjack/persistence/data_mapper/data_mapper.rb +0 -67
  56. data/lib/flapjack/persistence/data_mapper/models/check.rb +0 -90
  57. data/lib/flapjack/persistence/data_mapper/models/check_template.rb +0 -20
  58. data/lib/flapjack/persistence/data_mapper/models/event.rb +0 -19
  59. data/lib/flapjack/persistence/data_mapper/models/node.rb +0 -18
  60. data/lib/flapjack/persistence/data_mapper/models/related_check.rb +0 -15
  61. data/lib/flapjack/persistence/sqlite3.rb +0 -3
  62. data/lib/flapjack/persistence/sqlite3/sqlite3.rb +0 -166
  63. data/lib/flapjack/transports/beanstalkd.rb +0 -50
  64. data/lib/flapjack/transports/result.rb +0 -58
  65. data/lib/flapjack/worker/application.rb +0 -121
  66. data/lib/flapjack/worker/cli.rb +0 -49
@@ -18,6 +18,7 @@ require 'yajl/json_gem'
18
18
 
19
19
  require 'flapjack/data/entity_check'
20
20
  require 'flapjack/pikelet'
21
+ require 'flapjack/redis_pool'
21
22
  require 'flapjack/utility'
22
23
  require 'flapjack/version'
23
24
 
@@ -25,7 +26,7 @@ module Flapjack
25
26
 
26
27
  class Jabber < Blather::Client
27
28
 
28
- include Flapjack::Pikelet
29
+ include Flapjack::GenericPikelet
29
30
  include Flapjack::Utility
30
31
 
31
32
  log = Logger.new(STDOUT)
@@ -33,14 +34,26 @@ module Flapjack
33
34
  log.level = Logger::INFO
34
35
  Blather.logger = log
35
36
 
36
- def initialize
37
- super
37
+ alias_method :generic_bootstrap, :bootstrap
38
+ alias_method :generic_cleanup, :cleanup
39
+
40
+ def bootstrap(opts = {})
41
+ generic_bootstrap(opts)
42
+
43
+ @redis_config = opts[:redis_config]
44
+ @redis = Flapjack::RedisPool.new(:config => @redis_config, :size => 1)
45
+
38
46
  @buffer = []
39
47
  @hostname = Socket.gethostname
40
48
  end
41
49
 
50
+ def cleanup
51
+ @redis.empty! if @redis
52
+ @redis_handler.empty! if @redis_handler
53
+ generic_cleanup
54
+ end
55
+
42
56
  def setup
43
- @redis = build_redis_connection_pool
44
57
  @flapjack_jid = Blather::JID.new((@config['jabberid'] || 'flapjack') + '/' + @hostname)
45
58
 
46
59
  super(@flapjack_jid, @config['password'], @config['server'], @config['port'].to_i)
@@ -79,8 +92,8 @@ module Flapjack
79
92
 
80
93
  # Join the MUC Chat room after connecting.
81
94
  def on_ready(stanza)
82
- return if should_quit?
83
- @redis_handler ||= build_redis_connection_pool
95
+ return if should_quit? && @shutting_down
96
+ @redis_handler ||= Flapjack::RedisPool.new(:config => @redis_config, :size => 1)
84
97
  @connected_at = Time.now.to_i
85
98
  logger.info("Jabber Connected")
86
99
  if @config['rooms'] && @config['rooms'].length > 0
@@ -150,6 +163,8 @@ module Flapjack
150
163
  when command =~ /^help$/
151
164
  msg = "commands: \n"
152
165
  msg += " ACKID <id> <comment> [duration: <time spec>] \n"
166
+ msg += " find entities matching /pattern/ \n"
167
+ msg += " test notifications for <entity>[:<check>] \n"
153
168
  msg += " identify \n"
154
169
  msg += " help \n"
155
170
 
@@ -162,6 +177,43 @@ module Flapjack
162
177
  msg += "System CPU Time: #{t.stime}\n"
163
178
  msg += `uname -a`.chomp + "\n"
164
179
 
180
+ when command =~ /^test notifications for\s+([a-z0-9-]+)(:(.+))?$/i
181
+ entity_name = $1
182
+ check_name = $3 ? $3 : 'test'
183
+
184
+ msg = "so you want me to test notifications for entity: #{entity_name}, check: #{check_name} eh? ... well OK!"
185
+
186
+ entity = Flapjack::Data::Entity.find_by_name(entity_name, :redis => @redis_handler)
187
+ if entity
188
+ summary = "Testing notifications to all contacts interested in entity: #{entity.name}, check: #{check_name}"
189
+
190
+ entity_check = Flapjack::Data::EntityCheck.for_entity(entity, check_name, :redis => @redis_handler)
191
+ puts entity_check.inspect
192
+ entity_check.test_notifications('summary' => summary)
193
+
194
+ else
195
+ msg = "yeah, no i can't see #{entity_name} in my systems"
196
+ end
197
+
198
+ when command =~ /^(find )?entities matching\s+\/(.*)\/.*$/i
199
+ pattern = $2.chomp.strip
200
+ entity_list = Flapjack::Data::Entity.find_all_name_matching(pattern, :redis => @redis_handler)
201
+ max_showable = 30
202
+ number_found = entity_list.length
203
+ entity_list = entity_list[0..(max_showable - 1)] if number_found > max_showable
204
+
205
+ case
206
+ when number_found == 0
207
+ msg = "found no entities matching /#{pattern}/"
208
+ when number_found == 1
209
+ msg = "found #{number_found} entity matching /#{pattern}/ ... \n"
210
+ when number_found > max_showable
211
+ msg = "showing first #{max_showable} of #{number_found} entities found matching /#{pattern}/\n"
212
+ else
213
+ msg = "found #{number_found} entities matching /#{pattern}/ ... \n"
214
+ end
215
+ msg += entity_list.join(', ') unless entity_list.empty?
216
+
165
217
  when command =~ /^(.*)/
166
218
  words = $1
167
219
  msg = "what do you mean, '#{words}'? Type 'help' for a list of acceptable commands."
@@ -172,7 +224,7 @@ module Flapjack
172
224
  end
173
225
 
174
226
  def on_groupchat(stanza)
175
- return if should_quit?
227
+ return if should_quit? && @shutting_down
176
228
  logger.debug("groupchat message received: #{stanza.inspect}")
177
229
 
178
230
  if stanza.body =~ /^flapjack:\s+(.*)/
@@ -191,7 +243,7 @@ module Flapjack
191
243
  end
192
244
 
193
245
  def on_chat(stanza)
194
- return if should_quit?
246
+ return if should_quit? && @shutting_down
195
247
  logger.debug("chat message received: #{stanza.inspect}")
196
248
 
197
249
  if stanza.body =~ /^flapjack:\s+(.*)/
@@ -213,7 +265,7 @@ module Flapjack
213
265
 
214
266
  # returning true to prevent the reactor loop from stopping
215
267
  def on_disconnect(stanza)
216
- return true if should_quit?
268
+ return true if should_quit? && @shutting_down
217
269
  logger.warn("jabbers disconnected! reconnecting in 1 second ...")
218
270
  EventMachine::Timer.new(1) do
219
271
  connect # Blather::Client.connect
@@ -256,7 +308,7 @@ module Flapjack
256
308
  queue = @config['queue']
257
309
  events = {}
258
310
 
259
- until should_quit?
311
+ until should_quit? && @shutting_down
260
312
 
261
313
  # FIXME: should also check if presence has been established in any group chat rooms that are
262
314
  # configured before starting to process events, otherwise the first few may get lost (send
@@ -265,11 +317,12 @@ module Flapjack
265
317
  logger.debug("jabber is connected so commencing blpop on #{queue}")
266
318
  events[queue] = @redis.blpop(queue, 0)
267
319
  event = Yajl::Parser.parse(events[queue][1])
268
- type = event['notification_type']
320
+ type = event['notification_type'] || 'unknown'
269
321
  logger.debug('jabber notification event received')
270
322
  logger.debug(event.inspect)
271
323
  if 'shutdown'.eql?(type)
272
324
  if should_quit?
325
+ @shutting_down = true
273
326
  EventMachine::Synchrony.next_tick do
274
327
  # get delays without the next_tick
275
328
  close # Blather::Client.close
@@ -284,14 +337,30 @@ module Flapjack
284
337
 
285
338
  logger.debug("processing jabber notification address: #{address}, event: #{entity}:#{check}, state: #{state}, summary: #{summary}")
286
339
 
287
- ack_str = event['event_count'] && !state.eql?('ok') && !'acknowledgement'.eql?(type) ?
340
+ ack_str =
341
+ event['event_count'] &&
342
+ !state.eql?('ok') &&
343
+ !'acknowledgement'.eql?(type) &&
344
+ !'test'.eql?(type) ?
288
345
  "::: flapjack: ACKID #{event['event_count']} " : ''
289
346
 
290
- maint_str = (type && 'acknowledgement'.eql?(type)) ?
291
- "has been acknowledged, unscheduled maintenance created for #{duration}" :
347
+ type = 'unknown' unless type
348
+
349
+ maint_str = case type
350
+ when 'acknowledgement'
351
+ "has been acknowledged, unscheduled maintenance created for #{duration}"
352
+ when 'test'
353
+ ''
354
+ else
292
355
  "is #{state.upcase}"
356
+ end
357
+
358
+ # FIXME - should probably put all the message composition stuff in one place so
359
+ # the logic isn't duplicated in each notification channel.
360
+ # TODO - templatise the messages so they can be customised without changing core code
361
+ headline = "test".eql?(type.downcase) ? "TEST NOTIFICATION" : type.upcase
293
362
 
294
- msg = "#{type.upcase} #{ack_str}::: \"#{check}\" on #{entity} #{maint_str} ::: #{summary}"
363
+ msg = "#{headline} #{ack_str}::: \"#{check}\" on #{entity} #{maint_str} ::: #{summary}"
295
364
 
296
365
  chat_type = :chat
297
366
  chat_type = :groupchat if @config['rooms'] && @config['rooms'].include?(address)
@@ -307,9 +376,6 @@ module Flapjack
307
376
 
308
377
  count_timer.cancel
309
378
  keepalive_timer.cancel
310
-
311
- @redis.empty! if @redis
312
- @redis_handler.empty! if @redis_handler
313
379
  end
314
380
 
315
381
  end
@@ -5,47 +5,76 @@ require 'erb'
5
5
  require 'haml'
6
6
  require 'socket'
7
7
 
8
+ require 'flapjack/pikelet'
8
9
  require 'flapjack/data/entity_check'
9
- require 'flapjack/notification/common'
10
10
 
11
11
  module Flapjack
12
12
  module Notification
13
13
 
14
14
  class Email
15
- extend Flapjack::Notification::Common
16
-
17
- def self.dispatch(notification, opts = {})
18
- notification_type = notification['notification_type']
19
- contact_first_name = notification['contact_first_name']
20
- contact_last_name = notification['contact_last_name']
21
- state = notification['state']
22
- summary = notification['summary']
23
- time = notification['time']
24
- entity, check = notification['event_id'].split(':')
25
-
26
- entity_check = Flapjack::Data::EntityCheck.for_event_id(notification['event_id'],
27
- :redis => opts[:redis])
28
-
29
- headline_map = {'problem' => 'Problem: ',
30
- 'recovery' => 'Recovery: ',
31
- 'acknowledgement' => 'Acknowledgement: ',
32
- 'unknown' => ''
33
- }
34
-
35
- headline = headline_map[notification_type] || ''
36
-
37
- subject = "#{headline}'#{check}' on #{entity}"
38
- subject += " is #{state.upcase}" unless notification_type == 'acknowledgement'
39
-
40
- notification['subject'] = subject
41
- opts[:logger].debug "Flapjack::Notification::Email#dispatch is calling Flapjack::Notification::Mailer.sender, notification_id: #{notification['id']}"
42
- sender_opts = {:logger => opts[:logger],
43
- :in_scheduled_maintenance => entity_check.in_scheduled_maintenance?,
44
- :in_unscheduled_maintenance => entity_check.in_unscheduled_maintenance?
45
- }
46
-
47
- mail = prepare_email(notification, sender_opts)
48
- mail.deliver!
15
+
16
+ extend Flapjack::ResquePikelet
17
+
18
+ class << self
19
+
20
+ alias_method :orig_bootstrap, :bootstrap
21
+
22
+ # See https://github.com/mikel/mail/blob/master/lib/mail/mail.rb#L53
23
+ # & https://github.com/mikel/mail/blob/master/spec/mail/configuration_spec.rb
24
+ # for details of configuring mail gem. defaults to SMTP, localhost, port 25
25
+ def bootstrap(opts = {})
26
+ return if @bootstrapped
27
+
28
+ sc = opts[:config].delete('smtp_config')
29
+
30
+ if sc
31
+ smtp_config = sc.keys.inject({}) do |ret,obj|
32
+ ret[obj.to_sym] = sc[obj]
33
+ ret
34
+ end
35
+
36
+ Mail.defaults {
37
+ delivery_method :smtp, {:enable_starttls_auto => false}.merge(smtp_config)
38
+ }
39
+ end
40
+ orig_bootstrap(opts)
41
+ end
42
+
43
+ def perform(notification)
44
+ @logger.debug "Woo, got a notification to send out: #{notification.inspect}"
45
+ opts = {:logger => @logger}
46
+
47
+ notification_type = notification['notification_type']
48
+ contact_first_name = notification['contact_first_name']
49
+ contact_last_name = notification['contact_last_name']
50
+ state = notification['state']
51
+ summary = notification['summary']
52
+ time = notification['time']
53
+ entity, check = notification['event_id'].split(':')
54
+
55
+ entity_check = Flapjack::Data::EntityCheck.for_event_id(notification['event_id'],
56
+ :redis => ::Resque.redis)
57
+
58
+ headline_map = {'problem' => 'Problem: ',
59
+ 'recovery' => 'Recovery: ',
60
+ 'acknowledgement' => 'Acknowledgement: ',
61
+ 'test' => 'Test Notification: ',
62
+ 'unknown' => ''
63
+ }
64
+
65
+ headline = headline_map[notification_type] || ''
66
+
67
+ subject = "#{headline}'#{check}' on #{entity}"
68
+ subject += " is #{state.upcase}" unless ['acknowledgement', 'test'].include?(notification_type)
69
+
70
+ notification['subject'] = subject
71
+
72
+ mail = prepare_email(notification, :logger => @logger,
73
+ :in_scheduled_maintenance => entity_check.in_scheduled_maintenance?,
74
+ :in_unscheduled_maintenance => entity_check.in_unscheduled_maintenance?)
75
+ mail.deliver!
76
+ end
77
+
49
78
  end
50
79
 
51
80
  private
@@ -54,7 +83,7 @@ module Flapjack
54
83
 
55
84
  logger = opts[:logger]
56
85
 
57
- # not useing socket and gethostname as that doesn't give you a fqdn.
86
+ # not using socket and gethostname as that doesn't give you a fqdn.
58
87
  # see the facter issue: https://projects.puppetlabs.com/issues/3898
59
88
  fqdn = `/bin/hostname -f`.chomp
60
89
  m_from = "flapjack@#{fqdn}"
@@ -64,7 +93,8 @@ module Flapjack
64
93
  m_to = notification['address']
65
94
  m_subject = notification['subject']
66
95
 
67
- logger.debug("Flapjack::Notification::Mailer #{notification['id']} to: #{m_to} subject: #{m_subject}")
96
+ logger.debug("sending Flapjack::Notification::Email " +
97
+ "#{notification['id']} to: #{m_to} subject: #{m_subject}")
68
98
 
69
99
  @notification_type = notification['notification_type']
70
100
  @contact_first_name = notification['contact_first_name']
@@ -1,39 +1,51 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ require 'flapjack/pikelet'
3
4
  require 'flapjack/notification/sms/messagenet'
4
5
 
5
6
  module Flapjack
6
7
  module Notification
7
8
 
8
9
  class Sms
9
- extend Flapjack::Notification::Common
10
-
11
- def self.dispatch(notification, opts = {})
12
- notification_type = notification['notification_type']
13
- contact_first_name = notification['contact_first_name']
14
- contact_last_name = notification['contact_last_name']
15
- state = notification['state']
16
- summary = notification['summary']
17
- time = notification['time']
18
- entity, check = notification['event_id'].split(':')
19
-
20
- headline_map = {'problem' => 'PROBLEM: ',
21
- 'recovery' => 'RECOVERY: ',
22
- 'acknowledgement' => 'ACK: ',
23
- 'unknown' => '',
24
- '' => '',
25
- }
26
-
27
- headline = headline_map[notification_type] || ''
28
-
29
- message = "#{headline}'#{check}' on #{entity}"
30
- message += " is #{state.upcase}" unless notification_type == 'acknowledgement'
31
- message += " at #{Time.at(time).strftime('%-d %b %H:%M')}, #{summary}"
32
-
33
- notification['message'] = message
34
- Flapjack::Notification::Sms::Messagenet.sender(notification,
35
- :logger => opts[:logger],
36
- :config => Flapjack::Notification::Sms.class_variable_get('@@config'))
10
+
11
+ extend Flapjack::ResquePikelet
12
+
13
+ class << self
14
+
15
+ def perform(notification)
16
+ @logger.debug "Woo, got a notification to send out: #{notification.inspect}"
17
+ dispatch(notification, :logger => @logger, :redis => ::Resque.redis)
18
+ end
19
+
20
+ def dispatch(notification, opts = {})
21
+ notification_type = notification['notification_type']
22
+ contact_first_name = notification['contact_first_name']
23
+ contact_last_name = notification['contact_last_name']
24
+ state = notification['state']
25
+ summary = notification['summary']
26
+ time = notification['time']
27
+ entity, check = notification['event_id'].split(':')
28
+
29
+ headline_map = {'problem' => 'PROBLEM: ',
30
+ 'recovery' => 'RECOVERY: ',
31
+ 'acknowledgement' => 'ACK: ',
32
+ 'test' => 'TEST NOTIFICATION: ',
33
+ 'unknown' => '',
34
+ '' => '',
35
+ }
36
+
37
+ headline = headline_map[notification_type] || ''
38
+
39
+ message = "#{headline}'#{check}' on #{entity}"
40
+ message += " is #{state.upcase}" unless ['acknowledgement', 'test'].include?(notification_type)
41
+ message += " at #{Time.at(time).strftime('%-d %b %H:%M')}, #{summary}"
42
+
43
+ notification['message'] = message
44
+ Flapjack::Notification::Sms::Messagenet.sender(notification,
45
+ :logger => opts[:logger],
46
+ :config => Flapjack::Notification::Sms.instance_variable_get('@config'))
47
+ end
48
+
37
49
  end
38
50
 
39
51
  end
@@ -16,7 +16,7 @@ module Flapjack
16
16
 
17
17
  class Oobetet < Blather::Client
18
18
 
19
- include Flapjack::Pikelet
19
+ include Flapjack::GenericPikelet
20
20
  include Flapjack::Utility
21
21
 
22
22
  log = Logger.new(STDOUT)
@@ -1,44 +1,50 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'eventmachine'
4
- # the redis/synchrony gems need to be required in this particular order, see
5
- # the redis-rb README for details
6
- require 'hiredis'
7
3
  require 'em-synchrony'
8
4
  require 'em-synchrony/em-http'
9
- require 'redis/connection/synchrony'
10
- require 'redis'
11
5
 
12
6
  require 'yajl/json_gem'
13
7
 
14
8
  require 'flapjack/data/entity_check'
15
9
  require 'flapjack/data/global'
16
10
  require 'flapjack/pikelet'
11
+ require 'flapjack/redis_pool'
17
12
 
18
13
  module Flapjack
19
14
 
20
15
  class Pagerduty
21
16
 
22
- include Flapjack::Pikelet
17
+ include Flapjack::GenericPikelet
23
18
 
24
19
  PAGERDUTY_EVENTS_API_URL = 'https://events.pagerduty.com/generic/2010-04-15/create_event.json'
25
20
  SEM_PAGERDUTY_ACKS_RUNNING = 'sem_pagerduty_acks_running'
26
21
 
27
- def setup
28
- @redis = build_redis_connection_pool
22
+ alias_method :generic_bootstrap, :bootstrap
23
+ alias_method :generic_cleanup, :cleanup
24
+
25
+ def bootstrap(opts = {})
26
+ generic_bootstrap(opts)
27
+
28
+ @redis_config = opts[:redis_config]
29
+ @redis = Flapjack::RedisPool.new(:config => @redis_config, :size => 1)
30
+
29
31
  logger.debug("New Pagerduty pikelet with the following options: #{@config.inspect}")
30
32
 
31
33
  @pagerduty_acks_started = nil
32
34
  end
33
35
 
36
+ def cleanup
37
+ @redis.empty! if @redis
38
+ @redis_timer.empty! if @redis_timer
39
+ generic_cleanup
40
+ end
41
+
34
42
  def add_shutdown_event(opts = {})
35
43
  return unless redis = opts[:redis]
36
44
  redis.rpush(@config['queue'], JSON.generate('notification_type' => 'shutdown'))
37
45
  end
38
46
 
39
47
  def main
40
- setup
41
-
42
48
  logger.debug("pagerduty gateway - commencing main method")
43
49
  raise "Can't connect to the pagerduty API" unless test_pagerduty_connection
44
50
 
@@ -47,7 +53,7 @@ module Flapjack
47
53
  @redis.del(SEM_PAGERDUTY_ACKS_RUNNING)
48
54
 
49
55
  acknowledgement_timer = EM::Synchrony.add_periodic_timer(10) do
50
- @redis_timer ||= build_redis_connection_pool
56
+ @redis_timer ||= Flapjack::RedisPool.new(:config => @redis_config, :size => 1)
51
57
  find_pagerduty_acknowledgements_if_safe
52
58
  end
53
59
 
@@ -67,6 +73,8 @@ module Flapjack
67
73
  summary = event['summary']
68
74
  address = event['address']
69
75
 
76
+ headline = type.upcase
77
+
70
78
  case type.downcase
71
79
  when 'acknowledgement'
72
80
  maint_str = "has been acknowledged"
@@ -77,6 +85,10 @@ module Flapjack
77
85
  when 'recovery'
78
86
  maint_str = "is #{state.upcase}"
79
87
  pagerduty_type = "resolve"
88
+ when 'test'
89
+ maint_str = ""
90
+ pagerduty_type = "trigger"
91
+ headline = "TEST NOTIFICATION"
80
92
  end
81
93
 
82
94
  message = "#{type.upcase} - \"#{check}\" on #{entity} #{maint_str} - #{summary}"
@@ -91,9 +103,6 @@ module Flapjack
91
103
  end
92
104
 
93
105
  acknowledgement_timer.cancel
94
-
95
- @redis.empty! if @redis
96
- @redis_timer.empty! if @redis_timer
97
106
  end
98
107
 
99
108
  # considering this as part of the public API -- exposes it for testing.