flapjack 0.6.43 → 0.6.44
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/flapjack +4 -2
- data/bin/flapjack-nagios-receiver +4 -1
- data/bin/flapjack-populator +4 -1
- data/etc/flapjack_config.yaml.example +111 -106
- data/features/steps/notifications_steps.rb +6 -6
- data/lib/flapjack/configuration.rb +76 -24
- data/lib/flapjack/coordinator.rb +27 -44
- data/lib/flapjack/data/entity.rb +28 -7
- data/lib/flapjack/data/entity_check.rb +18 -20
- data/lib/flapjack/executive.rb +5 -4
- data/lib/flapjack/gateways/api.rb +391 -0
- data/lib/flapjack/gateways/api/entity_check_presenter.rb +185 -0
- data/lib/flapjack/gateways/api/entity_presenter.rb +70 -0
- data/lib/flapjack/gateways/base.rb +38 -0
- data/lib/flapjack/{notification → gateways}/email.rb +4 -5
- data/lib/flapjack/{notification → gateways}/email/alert.html.haml +0 -0
- data/lib/flapjack/{notification → gateways}/email/alert.text.erb +0 -0
- data/lib/flapjack/gateways/jabber.rb +387 -0
- data/lib/flapjack/gateways/oobetet.rb +241 -0
- data/lib/flapjack/gateways/pagerduty.rb +247 -0
- data/lib/flapjack/{notification → gateways}/sms.rb +5 -6
- data/lib/flapjack/{notification → gateways}/sms/messagenet.rb +1 -1
- data/lib/flapjack/gateways/web.rb +293 -0
- data/lib/flapjack/{web → gateways/web}/views/_css.haml +0 -0
- data/lib/flapjack/{web → gateways/web}/views/_nav.haml +0 -0
- data/lib/flapjack/{web → gateways/web}/views/check.haml +0 -0
- data/lib/flapjack/{web → gateways/web}/views/contact.haml +0 -0
- data/lib/flapjack/{web → gateways/web}/views/contacts.haml +0 -0
- data/lib/flapjack/{web → gateways/web}/views/index.haml +0 -0
- data/lib/flapjack/{web → gateways/web}/views/self_stats.haml +0 -0
- data/lib/flapjack/pikelet.rb +0 -23
- data/lib/flapjack/version.rb +1 -1
- data/spec/lib/flapjack/coordinator_spec.rb +56 -36
- data/spec/lib/flapjack/data/entity_spec.rb +53 -4
- data/spec/lib/flapjack/{api → gateways/api}/entity_check_presenter_spec.rb +10 -13
- data/spec/lib/flapjack/{api → gateways/api}/entity_presenter_spec.rb +10 -10
- data/spec/lib/flapjack/{api_spec.rb → gateways/api_spec.rb} +14 -14
- data/spec/lib/flapjack/gateways/email_spec.rb +6 -0
- data/spec/lib/flapjack/{jabber_spec.rb → gateways/jabber_spec.rb} +9 -9
- data/spec/lib/flapjack/{oobetet_spec.rb → gateways/oobetet_spec.rb} +10 -10
- data/spec/lib/flapjack/{pagerduty_spec.rb → gateways/pagerduty_spec.rb} +11 -11
- data/spec/lib/flapjack/gateways/sms_spec.rb +6 -0
- data/spec/lib/flapjack/{web_spec.rb → gateways/web_spec.rb} +4 -4
- metadata +46 -79
- data/bin/install-flapjack-systemwide +0 -58
- data/features/steps/flapjack-importer_steps.rb +0 -109
- data/features/steps/flapjack-worker_steps.rb +0 -68
- data/lib/flapjack/api.rb +0 -388
- data/lib/flapjack/api/entity_check_presenter.rb +0 -181
- data/lib/flapjack/api/entity_presenter.rb +0 -66
- data/lib/flapjack/cli/worker_manager.rb +0 -46
- data/lib/flapjack/inifile.rb +0 -44
- data/lib/flapjack/jabber.rb +0 -383
- data/lib/flapjack/notifier_engine.rb +0 -40
- data/lib/flapjack/notifiers/mailer/init.rb +0 -3
- data/lib/flapjack/notifiers/mailer/mailer.rb +0 -51
- data/lib/flapjack/notifiers/xmpp/init.rb +0 -3
- data/lib/flapjack/notifiers/xmpp/xmpp.rb +0 -46
- data/lib/flapjack/oobetet.rb +0 -240
- data/lib/flapjack/pagerduty.rb +0 -242
- data/lib/flapjack/web.rb +0 -286
- data/spec.old/check_sandbox/echo +0 -3
- data/spec.old/check_sandbox/sandboxed_check +0 -5
- data/spec.old/configs/flapjack-notifier-couchdb.ini +0 -25
- data/spec.old/configs/flapjack-notifier.ini +0 -39
- data/spec.old/configs/recipients.ini +0 -14
- data/spec.old/helpers.rb +0 -15
- data/spec.old/inifile_spec.rb +0 -66
- data/spec.old/mock-notifiers/mock/init.rb +0 -3
- data/spec.old/mock-notifiers/mock/mock.rb +0 -19
- data/spec.old/notifier-directories/spoons/testmailer/init.rb +0 -20
- data/spec.old/notifier_application_spec.rb +0 -222
- data/spec.old/notifier_filters_spec.rb +0 -52
- data/spec.old/notifier_options_multiplexer_spec.rb +0 -71
- data/spec.old/notifier_options_spec.rb +0 -115
- data/spec.old/notifier_spec.rb +0 -57
- data/spec.old/notifiers/mailer_spec.rb +0 -36
- data/spec.old/notifiers/xmpp_spec.rb +0 -36
- data/spec.old/persistence/datamapper_spec.rb +0 -74
- data/spec.old/persistence/mock_persistence_backend.rb +0 -26
- data/spec.old/simple.ini +0 -6
- data/spec.old/spec.opts +0 -4
- data/spec.old/test-filters/blocker.rb +0 -13
- data/spec.old/test-filters/mock.rb +0 -13
- data/spec.old/transports/beanstalkd_spec.rb +0 -44
- data/spec.old/transports/mock_transport.rb +0 -58
- data/spec.old/worker_application_spec.rb +0 -62
- data/spec.old/worker_options_spec.rb +0 -83
- data/spec/lib/flapjack/notification/email_spec.rb +0 -6
- 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
|
-
|
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(
|
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
|
-
|
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}'"
|
data/bin/flapjack-populator
CHANGED
@@ -43,7 +43,10 @@ end.parse!(ARGV)
|
|
43
43
|
|
44
44
|
FLAPJACK_ENV = ENV['FLAPJACK_ENV'] || 'development'
|
45
45
|
|
46
|
-
|
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
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
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
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
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
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
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
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
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
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
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
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
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::
|
131
|
+
Flapjack::Gateways::Sms.instance_variable_set('@config', {'username' => 'abcd', 'password' => 'efgh'})
|
132
132
|
|
133
133
|
lambda {
|
134
|
-
Flapjack::
|
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::
|
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::
|
150
|
+
Flapjack::Gateways::Email.bootstrap(:config => {})
|
151
151
|
lambda {
|
152
|
-
Flapjack::
|
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::
|
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
|