flapjack 0.6.43 → 0.6.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. data/bin/flapjack +4 -2
  2. data/bin/flapjack-nagios-receiver +4 -1
  3. data/bin/flapjack-populator +4 -1
  4. data/etc/flapjack_config.yaml.example +111 -106
  5. data/features/steps/notifications_steps.rb +6 -6
  6. data/lib/flapjack/configuration.rb +76 -24
  7. data/lib/flapjack/coordinator.rb +27 -44
  8. data/lib/flapjack/data/entity.rb +28 -7
  9. data/lib/flapjack/data/entity_check.rb +18 -20
  10. data/lib/flapjack/executive.rb +5 -4
  11. data/lib/flapjack/gateways/api.rb +391 -0
  12. data/lib/flapjack/gateways/api/entity_check_presenter.rb +185 -0
  13. data/lib/flapjack/gateways/api/entity_presenter.rb +70 -0
  14. data/lib/flapjack/gateways/base.rb +38 -0
  15. data/lib/flapjack/{notification → gateways}/email.rb +4 -5
  16. data/lib/flapjack/{notification → gateways}/email/alert.html.haml +0 -0
  17. data/lib/flapjack/{notification → gateways}/email/alert.text.erb +0 -0
  18. data/lib/flapjack/gateways/jabber.rb +387 -0
  19. data/lib/flapjack/gateways/oobetet.rb +241 -0
  20. data/lib/flapjack/gateways/pagerduty.rb +247 -0
  21. data/lib/flapjack/{notification → gateways}/sms.rb +5 -6
  22. data/lib/flapjack/{notification → gateways}/sms/messagenet.rb +1 -1
  23. data/lib/flapjack/gateways/web.rb +293 -0
  24. data/lib/flapjack/{web → gateways/web}/views/_css.haml +0 -0
  25. data/lib/flapjack/{web → gateways/web}/views/_nav.haml +0 -0
  26. data/lib/flapjack/{web → gateways/web}/views/check.haml +0 -0
  27. data/lib/flapjack/{web → gateways/web}/views/contact.haml +0 -0
  28. data/lib/flapjack/{web → gateways/web}/views/contacts.haml +0 -0
  29. data/lib/flapjack/{web → gateways/web}/views/index.haml +0 -0
  30. data/lib/flapjack/{web → gateways/web}/views/self_stats.haml +0 -0
  31. data/lib/flapjack/pikelet.rb +0 -23
  32. data/lib/flapjack/version.rb +1 -1
  33. data/spec/lib/flapjack/coordinator_spec.rb +56 -36
  34. data/spec/lib/flapjack/data/entity_spec.rb +53 -4
  35. data/spec/lib/flapjack/{api → gateways/api}/entity_check_presenter_spec.rb +10 -13
  36. data/spec/lib/flapjack/{api → gateways/api}/entity_presenter_spec.rb +10 -10
  37. data/spec/lib/flapjack/{api_spec.rb → gateways/api_spec.rb} +14 -14
  38. data/spec/lib/flapjack/gateways/email_spec.rb +6 -0
  39. data/spec/lib/flapjack/{jabber_spec.rb → gateways/jabber_spec.rb} +9 -9
  40. data/spec/lib/flapjack/{oobetet_spec.rb → gateways/oobetet_spec.rb} +10 -10
  41. data/spec/lib/flapjack/{pagerduty_spec.rb → gateways/pagerduty_spec.rb} +11 -11
  42. data/spec/lib/flapjack/gateways/sms_spec.rb +6 -0
  43. data/spec/lib/flapjack/{web_spec.rb → gateways/web_spec.rb} +4 -4
  44. metadata +46 -79
  45. data/bin/install-flapjack-systemwide +0 -58
  46. data/features/steps/flapjack-importer_steps.rb +0 -109
  47. data/features/steps/flapjack-worker_steps.rb +0 -68
  48. data/lib/flapjack/api.rb +0 -388
  49. data/lib/flapjack/api/entity_check_presenter.rb +0 -181
  50. data/lib/flapjack/api/entity_presenter.rb +0 -66
  51. data/lib/flapjack/cli/worker_manager.rb +0 -46
  52. data/lib/flapjack/inifile.rb +0 -44
  53. data/lib/flapjack/jabber.rb +0 -383
  54. data/lib/flapjack/notifier_engine.rb +0 -40
  55. data/lib/flapjack/notifiers/mailer/init.rb +0 -3
  56. data/lib/flapjack/notifiers/mailer/mailer.rb +0 -51
  57. data/lib/flapjack/notifiers/xmpp/init.rb +0 -3
  58. data/lib/flapjack/notifiers/xmpp/xmpp.rb +0 -46
  59. data/lib/flapjack/oobetet.rb +0 -240
  60. data/lib/flapjack/pagerduty.rb +0 -242
  61. data/lib/flapjack/web.rb +0 -286
  62. data/spec.old/check_sandbox/echo +0 -3
  63. data/spec.old/check_sandbox/sandboxed_check +0 -5
  64. data/spec.old/configs/flapjack-notifier-couchdb.ini +0 -25
  65. data/spec.old/configs/flapjack-notifier.ini +0 -39
  66. data/spec.old/configs/recipients.ini +0 -14
  67. data/spec.old/helpers.rb +0 -15
  68. data/spec.old/inifile_spec.rb +0 -66
  69. data/spec.old/mock-notifiers/mock/init.rb +0 -3
  70. data/spec.old/mock-notifiers/mock/mock.rb +0 -19
  71. data/spec.old/notifier-directories/spoons/testmailer/init.rb +0 -20
  72. data/spec.old/notifier_application_spec.rb +0 -222
  73. data/spec.old/notifier_filters_spec.rb +0 -52
  74. data/spec.old/notifier_options_multiplexer_spec.rb +0 -71
  75. data/spec.old/notifier_options_spec.rb +0 -115
  76. data/spec.old/notifier_spec.rb +0 -57
  77. data/spec.old/notifiers/mailer_spec.rb +0 -36
  78. data/spec.old/notifiers/xmpp_spec.rb +0 -36
  79. data/spec.old/persistence/datamapper_spec.rb +0 -74
  80. data/spec.old/persistence/mock_persistence_backend.rb +0 -26
  81. data/spec.old/simple.ini +0 -6
  82. data/spec.old/spec.opts +0 -4
  83. data/spec.old/test-filters/blocker.rb +0 -13
  84. data/spec.old/test-filters/mock.rb +0 -13
  85. data/spec.old/transports/beanstalkd_spec.rb +0 -44
  86. data/spec.old/transports/mock_transport.rb +0 -58
  87. data/spec.old/worker_application_spec.rb +0 -62
  88. data/spec.old/worker_options_spec.rb +0 -83
  89. data/spec/lib/flapjack/notification/email_spec.rb +0 -6
  90. data/spec/lib/flapjack/notification/sms_spec.rb +0 -6
data/bin/flapjack CHANGED
@@ -33,7 +33,9 @@ end.parse!(ARGV)
33
33
 
34
34
  FLAPJACK_ENV = ENV['FLAPJACK_ENV'] || 'development'
35
35
 
36
- config_env, redis_options = Flapjack::Configuration.new.load(options.config)
36
+ config = Flapjack::Configuration.new
37
+ config.load(options.config)
38
+ config_env = config.all
37
39
 
38
40
  if config_env.nil? || config_env.empty?
39
41
  puts "No config data for environment '#{FLAPJACK_ENV}' found in '#{options.config}'"
@@ -50,7 +52,7 @@ end
50
52
 
51
53
  require 'flapjack/coordinator'
52
54
 
53
- coordinator = Flapjack::Coordinator.new(config_env, redis_options)
55
+ coordinator = Flapjack::Coordinator.new(config)
54
56
  coordinator.log_file = (config_env['log_file'] || 'log/flapjack.log')
55
57
  coordinator.pid_file = pid_file
56
58
 
@@ -31,7 +31,10 @@ end.parse!(ARGV)
31
31
 
32
32
  FLAPJACK_ENV = ENV['FLAPJACK_ENV'] || 'development'
33
33
 
34
- @config_env, @redis_options = Flapjack::Configuration.new.load(options.config)
34
+ config = Flapjack::Configuration.new
35
+ config.load(options.config)
36
+ @config_env = config.all
37
+ @redis_options = @config.for_redis
35
38
 
36
39
  if @config_env.nil? || @config_env.empty?
37
40
  puts "No config data for environment '#{FLAPJACK_ENV}' found in '#{options.config}'"
@@ -43,7 +43,10 @@ end.parse!(ARGV)
43
43
 
44
44
  FLAPJACK_ENV = ENV['FLAPJACK_ENV'] || 'development'
45
45
 
46
- config_env, redis_options = Flapjack::Configuration.new.load(options.config)
46
+ config = Flapjack::Configuration.new
47
+ config.load(options.config)
48
+ config_env = config.all
49
+ redis_options = config.for_redis
47
50
 
48
51
  if config_env.nil? || config_env.empty?
49
52
  puts "No config data for environment '#{FLAPJACK_ENV}' found in '#{options.config}'"
@@ -9,16 +9,17 @@ quickstart:
9
9
  enabled: yes
10
10
  email_queue: email_notifications
11
11
  notification_log_file: log/flapjack-notification.log
12
- email_notifier:
13
- enabled: yes
14
- queue: email_notifications
15
- smtp_config:
16
- address: "localhost"
17
- domain: 'localhost.localdomain'
18
- port: 25
19
- web:
20
- enabled: yes
21
- port: 5080
12
+ gateways:
13
+ email:
14
+ enabled: yes
15
+ queue: email_notifications
16
+ smtp_config:
17
+ address: "localhost"
18
+ domain: 'localhost.localdomain'
19
+ port: 25
20
+ web:
21
+ enabled: yes
22
+ port: 5080
22
23
 
23
24
  development:
24
25
  pid_file: tmp/pids/flapjack.pid
@@ -34,97 +35,100 @@ development:
34
35
  sms_queue: sms_notifications
35
36
  jabber_queue: jabber_notifications
36
37
  notification_log_file: log/flapjack-notification.log
37
- email_notifier:
38
- enabled: yes
39
- queue: email_notifications
40
- smtp_config:
41
- port: 2525
42
- # address: "localhost"
43
- # port: 25
44
- # domain: 'localhost.localdomain'
45
- # user_name: nil
46
- # password: nil
47
- # authentication: nil
48
- # enable_starttls_auto: true
49
- sms_notifier:
50
- enabled: yes
51
- queue: sms_notifications
52
- username: "ermahgerd"
53
- password: "xxxx"
54
- jabber_gateway:
55
- enabled: yes
56
- queue: jabber_notifications
57
- server: "jabber.domain.tld"
58
- port: 5222
59
- jabberid: "flapjack@jabber.domain.tld"
60
- password: "good-password"
61
- alias: "flapjack"
62
- rooms:
63
- - "gimp@conference.jabber.domain.tld"
64
- - "log@conference.jabber.domain.tld"
65
- oobetet:
66
- enabled: yes
67
- server: "jabber.domain.tld"
68
- port: 5222
69
- jabberid: "flapjacktest@jabber.domain.tld"
70
- password: "nuther-good-password"
71
- alias: "flapjacktest"
72
- watched_check: "PING"
73
- watched_entity: "foo.bar.net"
74
- max_latency: 300
75
- pagerduty_contact: "11111111111111111111111111111111"
76
- rooms:
77
- - "flapjacktest@conference.jabber.domain.tld"
78
- - "gimp@conference.jabber.domain.tld"
79
- - "log@conference.jabber.domain.tld"
80
- pagerduty_gateway:
81
- enabled: yes
82
- queue: pagerduty_notifications
83
- web:
84
- enabled: yes
85
- port: 5080
86
- access_log: "log/web_access.log"
87
- api:
88
- enabled: yes
89
- port: 5081
90
- access_log: "log/api_access.log"
38
+ gateways:
39
+ email:
40
+ enabled: yes
41
+ queue: email_notifications
42
+ smtp_config:
43
+ port: 2525
44
+ # address: "localhost"
45
+ # port: 25
46
+ # domain: 'localhost.localdomain'
47
+ # user_name: nil
48
+ # password: nil
49
+ # authentication: nil
50
+ # enable_starttls_auto: true
51
+ sms:
52
+ enabled: yes
53
+ queue: sms_notifications
54
+ username: "ermahgerd"
55
+ password: "xxxx"
56
+ jabber:
57
+ enabled: yes
58
+ queue: jabber_notifications
59
+ server: "jabber.domain.tld"
60
+ port: 5222
61
+ jabberid: "flapjack@jabber.domain.tld"
62
+ password: "good-password"
63
+ alias: "flapjack"
64
+ rooms:
65
+ - "gimp@conference.jabber.domain.tld"
66
+ - "log@conference.jabber.domain.tld"
67
+ oobetet:
68
+ enabled: yes
69
+ server: "jabber.domain.tld"
70
+ port: 5222
71
+ jabberid: "flapjacktest@jabber.domain.tld"
72
+ password: "nuther-good-password"
73
+ alias: "flapjacktest"
74
+ watched_check: "PING"
75
+ watched_entity: "foo.bar.net"
76
+ max_latency: 300
77
+ pagerduty_contact: "11111111111111111111111111111111"
78
+ rooms:
79
+ - "flapjacktest@conference.jabber.domain.tld"
80
+ - "gimp@conference.jabber.domain.tld"
81
+ - "log@conference.jabber.domain.tld"
82
+ pagerduty:
83
+ enabled: yes
84
+ queue: pagerduty_notifications
85
+ web:
86
+ enabled: yes
87
+ port: 5080
88
+ access_log: "log/web_access.log"
89
+ api:
90
+ enabled: yes
91
+ port: 5081
92
+ access_log: "log/api_access.log"
91
93
 
92
94
  test:
93
95
  redis:
94
96
  database: 14
95
- email_notifier:
96
- instances: 1
97
- sms_notifier:
98
- instances: 1
99
- username: "ermahgerd"
100
- password: "xxxx"
101
- web:
102
- instances: 1
103
-
97
+ gateways:
98
+ email:
99
+ instances: 1
100
+ sms:
101
+ instances: 1
102
+ username: "ermahgerd"
103
+ password: "xxxx"
104
+ web:
105
+ instances: 1
104
106
 
105
107
  staging:
106
108
  redis:
107
109
  database: 15
108
- email_notifier:
109
- instances: 1
110
- sms_notifier:
111
- instances: 1
112
- username: "ermahgerd"
113
- password: "xxxx"
114
- web:
115
- instances: 1
110
+ gateways:
111
+ email:
112
+ instances: 1
113
+ sms:
114
+ instances: 1
115
+ username: "ermahgerd"
116
+ password: "xxxx"
117
+ web:
118
+ instances: 1
116
119
 
117
120
  production:
118
121
  redis:
119
122
  database: 12
120
- email_notifier:
121
- instances: 1
122
- sms_notifier:
123
- instances: 1
124
- username: "ermahgerd"
125
- password: "xxxx"
126
- web:
127
- instances: 1
123
+ gateways:
124
+ email:
125
+ instances: 1
126
+ sms:
127
+ instances: 1
128
+ username: "ermahgerd"
129
+ password: "xxxx"
130
+ web:
131
+ instances: 1
128
132
 
129
133
  profile:
130
134
  redis:
@@ -134,20 +138,21 @@ profile:
134
138
  executive:
135
139
  enabled: yes
136
140
  notification_log_file: log/flapjack-notification.log
137
- email_notifier:
138
- enabled: no
139
- queue: email_notifications
140
- jabber_gateway:
141
- enabled: yes
142
- queue: jabber_notifications
143
- server: "jabber.domain.tld"
144
- port: 5222
145
- jabberid: "flapjack@jabber.domain.tld"
146
- password: "good-password"
147
- alias: "flapjack"
148
- rooms:
149
- - "gimp@conference.jabber.domain.tld"
150
- - "log@conference.jabber.domain.tld"
151
- web:
152
- enabled: no
153
- port: 5080
141
+ gateways:
142
+ email:
143
+ enabled: no
144
+ queue: email_notifications
145
+ jabber:
146
+ enabled: yes
147
+ queue: jabber_notifications
148
+ server: "jabber.domain.tld"
149
+ port: 5222
150
+ jabberid: "flapjack@jabber.domain.tld"
151
+ password: "good-password"
152
+ alias: "flapjack"
153
+ rooms:
154
+ - "gimp@conference.jabber.domain.tld"
155
+ - "log@conference.jabber.domain.tld"
156
+ web:
157
+ enabled: no
158
+ port: 5080
@@ -128,10 +128,10 @@ When /^the SMS notification handler runs successfully$/ do
128
128
  # returns success by default - currently matches all addresses, maybe load from config?
129
129
  stub_request(:get, /.*/)
130
130
  # TODO load config from cfg file instead?
131
- Flapjack::Notification::Sms.instance_variable_set('@config', {'username' => 'abcd', 'password' => 'efgh'})
131
+ Flapjack::Gateways::Sms.instance_variable_set('@config', {'username' => 'abcd', 'password' => 'efgh'})
132
132
 
133
133
  lambda {
134
- Flapjack::Notification::Sms.dispatch(@sms_notification, :logger => @logger, :redis => @redis)
134
+ Flapjack::Gateways::Sms.dispatch(@sms_notification, :logger => @logger, :redis => @redis)
135
135
  }.should_not raise_error
136
136
  @sms_sent = true
137
137
  end
@@ -140,16 +140,16 @@ When /^the SMS notification handler fails to send an SMS$/ do
140
140
  stub_request(:any, /.*/).to_return(:status => [500, "Internal Server Error"])
141
141
 
142
142
  lambda {
143
- Flapjack::Notification::Sms.dispatch(@sms_notification, :logger => @logger, :redis => @redis)
143
+ Flapjack::Gateways::Sms.dispatch(@sms_notification, :logger => @logger, :redis => @redis)
144
144
  }.should raise_error
145
145
  @sms_sent = false
146
146
  end
147
147
 
148
148
  When /^the email notification handler runs successfully$/ do
149
149
  Resque.redis = @redis
150
- Flapjack::Notification::Email.bootstrap(:config => {})
150
+ Flapjack::Gateways::Email.bootstrap(:config => {})
151
151
  lambda {
152
- Flapjack::Notification::Email.perform(@email_notification)
152
+ Flapjack::Gateways::Email.perform(@email_notification)
153
153
  }.should_not raise_error
154
154
  end
155
155
 
@@ -160,7 +160,7 @@ When /^the email notification handler fails to send an email$/ do
160
160
  pending
161
161
  lambda {
162
162
  @email_notification['address'] = nil
163
- Flapjack::Notification::Email.perform(@email_notification)
163
+ Flapjack::Gateways::Email.perform(@email_notification)
164
164
  }.should_not raise_error
165
165
  end
166
166
 
@@ -3,6 +3,16 @@
3
3
  require 'yaml'
4
4
  require 'logger'
5
5
 
6
+ require 'flapjack/executive'
7
+
8
+ require 'flapjack/gateways/api'
9
+ require 'flapjack/gateways/jabber'
10
+ require 'flapjack/gateways/oobetet'
11
+ require 'flapjack/gateways/pagerduty'
12
+ require 'flapjack/gateways/email'
13
+ require 'flapjack/gateways/sms'
14
+ require 'flapjack/gateways/web'
15
+
6
16
  module Flapjack
7
17
 
8
18
  class Configuration
@@ -19,6 +29,70 @@ module Flapjack
19
29
  @logger
20
30
  end
21
31
 
32
+ # TODO reduce/remove the use of this, just access parts
33
+ def all
34
+ @config_env
35
+ end
36
+
37
+ def for_redis
38
+ return unless @config_env
39
+
40
+ redis_defaults = {'host' => 'localhost',
41
+ 'port' => 6379,
42
+ 'path' => nil,
43
+ 'db' => 0}
44
+
45
+ @config_env['redis'] = {} unless @config_env.has_key?('redis')
46
+
47
+ redis = @config_env['redis']
48
+ redis_defaults.each_pair do |k,v|
49
+ next if redis.has_key?(k) && redis[k] &&
50
+ !(redis[k].is_a?(String) && redis[k].empty?)
51
+ redis[k] = v
52
+ end
53
+
54
+ redis_path = (redis['path'] || nil)
55
+ base_opts = {:db => (redis['db'] || 0)}
56
+ redis_config = base_opts.merge(
57
+ (redis_path ? { :path => redis_path } :
58
+ { :host => (redis['host'] || '127.0.0.1'),
59
+ :port => (redis['port'] || 6379)})
60
+ )
61
+
62
+ redis_config
63
+ end
64
+
65
+ PIKELET_TYPES = {'executive' => Flapjack::Executive}
66
+
67
+ GATEWAY_TYPES = {'web' => Flapjack::Gateways::Web,
68
+ 'api' => Flapjack::Gateways::API,
69
+ 'jabber' => Flapjack::Gateways::Jabber,
70
+ 'pagerduty' => Flapjack::Gateways::Pagerduty,
71
+ 'oobetet' => Flapjack::Gateways::Oobetet,
72
+ 'email' => Flapjack::Gateways::Email,
73
+ 'sms' => Flapjack::Gateways::Sms}
74
+
75
+ def pikelets
76
+ return {} unless @config_env
77
+ @config_env.inject({}) {|memo, (k, v)|
78
+ if klass = PIKELET_TYPES[k]
79
+ memo[klass] = v
80
+ end
81
+ memo
82
+ }
83
+ end
84
+
85
+ def gateways
86
+ return {} unless @config_env && @config_env['gateways'] &&
87
+ !@config_env['gateways'].nil?
88
+ @config_env['gateways'].inject({}) {|memo, (k, v)|
89
+ if klass = GATEWAY_TYPES[k]
90
+ memo[klass] = v
91
+ end
92
+ memo
93
+ }
94
+ end
95
+
22
96
  def load(filename)
23
97
  unless File.file?(filename)
24
98
  logger.error "Could not find file '#{filename}'"
@@ -37,34 +111,12 @@ module Flapjack
37
111
  return
38
112
  end
39
113
 
40
- config_env = config[FLAPJACK_ENV]
114
+ @config_env = config[FLAPJACK_ENV]
41
115
 
42
- if config_env.nil?
116
+ if @config_env.nil?
43
117
  logger.error "No config data for environment '#{FLAPJACK_ENV}' found in '#{filename}'"
44
118
  return
45
119
  end
46
-
47
- redis_defaults = {'host' => 'localhost',
48
- 'port' => 6379,
49
- 'path' => nil,
50
- 'db' => 0}
51
-
52
- config_env['redis'] = {} unless config_env.has_key?('redis')
53
- redis_defaults.each_pair do |k,v|
54
- next if config_env['redis'].has_key?(k) && (config_env['redis'][k] &&
55
- !(config_env['redis'][k].is_a?(String) && config_env['redis'][k].empty?))
56
- config_env['redis'][k] = v
57
- end
58
-
59
- redis_path = (config_env['redis']['path'] || nil)
60
- base_opts = {:db => (config_env['redis']['db'] || 0)}
61
- redis_config = base_opts.merge(
62
- (redis_path ? { :path => redis_path } :
63
- { :host => (config_env['redis']['host'] || '127.0.0.1'),
64
- :port => (config_env['redis']['port'] || 6379)})
65
- )
66
-
67
- return config_env, redis_config
68
120
  end
69
121
 
70
122
  end