flapjack 0.5.5 → 0.6.23
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.
- data/.gitignore +10 -0
- data/.rbenv-version +1 -0
- data/.rspec +10 -0
- data/Gemfile +18 -0
- data/Guardfile +14 -0
- data/README.md +152 -173
- data/Rakefile +53 -150
- data/bin/flapjack +72 -0
- data/bin/flapjack-nagios-receiver +111 -0
- data/bin/flapjack-nagios-receiver-control +15 -0
- data/bin/flapjack-netsaint-parser +0 -2
- data/bin/flapjack-populator +133 -16
- data/bin/install-flapjack-systemwide +2 -2
- data/config.ru +11 -0
- data/dist/etc/init.d/flapjack +46 -0
- data/dist/etc/init.d/flapjack-nagios-receiver +36 -0
- data/doc/GLOSSARY.md +19 -0
- data/etc/flapjack_config.yaml.example +90 -0
- data/features/events.feature +132 -0
- data/features/notifications.feature +57 -0
- data/features/packaging-lintian.feature +5 -3
- data/features/steps/events_steps.rb +164 -0
- data/features/steps/flapjack-importer_steps.rb +2 -5
- data/features/steps/flapjack-worker_steps.rb +13 -6
- data/features/steps/notifications_steps.rb +178 -0
- data/features/steps/packaging-lintian_steps.rb +14 -0
- data/features/steps/time_travel_steps.rb +34 -0
- data/features/support/env.rb +63 -36
- data/flapjack.gemspec +35 -186
- data/lib/flapjack.rb +2 -0
- data/lib/flapjack/api.rb +274 -0
- data/lib/flapjack/api/entity_check_presenter.rb +184 -0
- data/lib/flapjack/api/entity_presenter.rb +66 -0
- data/lib/flapjack/cli/worker_manager.rb +1 -2
- data/lib/flapjack/configuration.rb +11 -0
- data/lib/flapjack/coordinator.rb +288 -0
- data/lib/flapjack/daemonizing.rb +186 -0
- data/lib/flapjack/data/contact.rb +45 -0
- data/lib/flapjack/data/entity.rb +89 -0
- data/lib/flapjack/data/entity_check.rb +396 -0
- data/lib/flapjack/data/event.rb +144 -0
- data/lib/flapjack/data/notification.rb +13 -0
- data/lib/flapjack/executive.rb +289 -0
- data/lib/flapjack/filters/acknowledgement.rb +39 -0
- data/lib/flapjack/filters/{any_parents_failed.rb → base.rb} +6 -4
- data/lib/flapjack/filters/delays.rb +53 -0
- data/lib/flapjack/filters/detect_mass_client_failures.rb +44 -0
- data/lib/flapjack/filters/ok.rb +25 -5
- data/lib/flapjack/filters/scheduled_maintenance.rb +17 -0
- data/lib/flapjack/filters/unscheduled_maintenance.rb +17 -0
- data/lib/flapjack/jabber.rb +294 -0
- data/lib/flapjack/notification/common.rb +23 -0
- data/lib/flapjack/notification/email.rb +107 -0
- data/lib/flapjack/notification/email/alert.html.haml +48 -0
- data/lib/flapjack/notification/email/alert.text.erb +14 -0
- data/lib/flapjack/notification/sms.rb +42 -0
- data/lib/flapjack/notification/sms/messagenet.rb +49 -0
- data/lib/flapjack/notifier_engine.rb +4 -4
- data/lib/flapjack/notifiers/mailer/mailer.rb +6 -7
- data/lib/flapjack/notifiers/xmpp/xmpp.rb +12 -12
- data/lib/flapjack/pagerduty.rb +230 -0
- data/lib/flapjack/patches.rb +108 -19
- data/lib/flapjack/persistence/data_mapper/models/check.rb +5 -3
- data/lib/flapjack/persistence/data_mapper/models/check_template.rb +2 -0
- data/lib/flapjack/persistence/data_mapper/models/event.rb +2 -0
- data/lib/flapjack/persistence/data_mapper/models/node.rb +3 -1
- data/lib/flapjack/persistence/data_mapper/models/related_check.rb +3 -1
- data/lib/flapjack/pikelet.rb +56 -0
- data/lib/flapjack/transports/beanstalkd.rb +1 -1
- data/lib/flapjack/transports/result.rb +6 -6
- data/lib/flapjack/utility.rb +46 -0
- data/lib/flapjack/version.rb +5 -0
- data/lib/flapjack/web.rb +198 -0
- data/lib/flapjack/web/views/acknowledge.haml +55 -0
- data/lib/flapjack/web/views/check.haml +162 -0
- data/lib/flapjack/web/views/index.haml +92 -0
- data/lib/flapjack/web/views/self_stats.haml +56 -0
- data/lib/flapjack/{applications/worker.rb → worker/application.rb} +0 -0
- data/lib/flapjack/worker/cli.rb +49 -0
- data/{spec → spec.old}/check_sandbox/echo +0 -0
- data/{spec → spec.old}/check_sandbox/sandboxed_check +0 -0
- data/{spec → spec.old}/configs/flapjack-notifier-couchdb.ini +0 -0
- data/{spec → spec.old}/configs/flapjack-notifier.ini +0 -0
- data/{spec → spec.old}/configs/recipients.ini +0 -0
- data/{spec → spec.old}/helpers.rb +0 -0
- data/{spec → spec.old}/inifile_spec.rb +0 -0
- data/{spec → spec.old}/mock-notifiers/mock/init.rb +0 -0
- data/{spec → spec.old}/mock-notifiers/mock/mock.rb +0 -0
- data/{spec → spec.old}/notifier-directories/spoons/testmailer/init.rb +0 -0
- data/{spec → spec.old}/notifier_application_spec.rb +0 -0
- data/{spec → spec.old}/notifier_filters_spec.rb +0 -0
- data/{spec → spec.old}/notifier_options_multiplexer_spec.rb +0 -0
- data/{spec → spec.old}/notifier_options_spec.rb +0 -0
- data/{spec → spec.old}/notifier_spec.rb +0 -0
- data/{spec → spec.old}/notifiers/mailer_spec.rb +0 -0
- data/{spec → spec.old}/notifiers/xmpp_spec.rb +0 -0
- data/{spec → spec.old}/persistence/datamapper_spec.rb +0 -0
- data/{spec → spec.old}/persistence/mock_persistence_backend.rb +0 -0
- data/{spec → spec.old}/simple.ini +0 -0
- data/{spec → spec.old}/spec.opts +0 -0
- data/{spec → spec.old}/test-filters/blocker.rb +0 -0
- data/{spec → spec.old}/test-filters/mock.rb +0 -0
- data/{spec → spec.old}/transports/beanstalkd_spec.rb +0 -0
- data/{spec → spec.old}/transports/mock_transport.rb +0 -0
- data/{spec → spec.old}/worker_application_spec.rb +0 -0
- data/{spec → spec.old}/worker_options_spec.rb +0 -0
- data/spec/lib/flapjack/api/entity_check_presenter_spec.rb +117 -0
- data/spec/lib/flapjack/api/entity_presenter_spec.rb +92 -0
- data/spec/lib/flapjack/api_spec.rb +170 -0
- data/spec/lib/flapjack/coordinator_spec.rb +16 -0
- data/spec/lib/flapjack/data/entity_check_spec.rb +398 -0
- data/spec/lib/flapjack/data/entity_spec.rb +71 -0
- data/spec/lib/flapjack/data/event_spec.rb +6 -0
- data/spec/lib/flapjack/executive_spec.rb +59 -0
- data/spec/lib/flapjack/filters/acknowledgement_spec.rb +6 -0
- data/spec/lib/flapjack/filters/delays_spec.rb +6 -0
- data/spec/lib/flapjack/filters/detect_mass_client_failures_spec.rb +6 -0
- data/spec/lib/flapjack/filters/ok_spec.rb +6 -0
- data/spec/lib/flapjack/filters/scheduled_maintenance_spec.rb +6 -0
- data/spec/lib/flapjack/filters/unscheduled_maintenance_spec.rb +6 -0
- data/spec/lib/flapjack/jabber_spec.rb +150 -0
- data/spec/lib/flapjack/notification/email_spec.rb +6 -0
- data/spec/lib/flapjack/notification/sms_spec.rb +6 -0
- data/spec/lib/flapjack/pikelet_spec.rb +28 -0
- data/spec/lib/flapjack/web_spec.rb +188 -0
- data/spec/spec_helper.rb +44 -0
- data/spec/support/profile_all_formatter.rb +44 -0
- data/spec/support/uncolored_doc_formatter.rb +9 -0
- data/tasks/events.rake +85 -0
- data/tmp/acknowledge.rb +14 -0
- data/tmp/create_config_yaml.rb +16 -0
- data/tmp/create_events_failure.rb +33 -0
- data/tmp/create_events_ok.rb +33 -0
- data/tmp/create_events_ok_fail_ack_ok.rb +54 -0
- data/tmp/create_events_ok_failure.rb +40 -0
- data/tmp/create_events_ok_failure_ack.rb +54 -0
- data/tmp/dummy_entities.json +1 -0
- data/tmp/generate_nagios_test_hosts.rb +16 -0
- data/tmp/parse_config_yaml.rb +7 -0
- data/tmp/redis_delete_all_keys.rb +11 -0
- data/tmp/test_entities.json +1 -0
- metadata +482 -221
- data/TODO.md +0 -36
- data/VERSION +0 -1
- data/bin/flapjack-benchmark +0 -50
- data/bin/flapjack-notifier +0 -21
- data/bin/flapjack-notifier-manager +0 -43
- data/bin/flapjack-stats +0 -27
- data/bin/flapjack-worker +0 -13
- data/bin/flapjack-worker-manager +0 -35
- data/dist/etc/init.d/flapjack-notifier +0 -47
- data/dist/etc/init.d/flapjack-workers +0 -44
- data/features/flapjack-notifier-manager.feature +0 -19
- data/features/flapjack-worker-manager.feature +0 -27
- data/features/flapjack-worker.feature +0 -27
- data/features/netsaint-config-converter.feature +0 -126
- data/features/persistence/couch.feature +0 -105
- data/features/persistence/sqlite3.feature +0 -105
- data/features/persistence/steps/couch_steps.rb +0 -25
- data/features/persistence/steps/generic_steps.rb +0 -102
- data/features/persistence/steps/sqlite3_steps.rb +0 -13
- data/features/steps/flapjack-notifier-manager_steps.rb +0 -24
- data/features/steps/flapjack-worker-manager_steps.rb +0 -48
- data/lib/flapjack/applications/notifier.rb +0 -222
- data/lib/flapjack/cli/notifier.rb +0 -108
- data/lib/flapjack/cli/notifier_manager.rb +0 -86
- data/lib/flapjack/cli/worker.rb +0 -51
|
@@ -71,14 +71,11 @@ end
|
|
|
71
71
|
Given /^beanstalkd is running$/ do
|
|
72
72
|
system("which beanstalkd > /dev/null 2>&1").should be_true
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
command = "beanstalkd"
|
|
75
|
+
@beanstalk = spawn_daemon(command)
|
|
75
76
|
|
|
76
77
|
# So beanstalkd has a moment to catch its breath.
|
|
77
78
|
sleep 0.5
|
|
78
|
-
|
|
79
|
-
at_exit do
|
|
80
|
-
Process.kill("KILL", @beanstalk.pid)
|
|
81
|
-
end
|
|
82
79
|
end
|
|
83
80
|
|
|
84
81
|
Given /^there are no jobs on the "([^"]*)" beanstalkd queue$/ do |queue_name|
|
|
@@ -14,15 +14,11 @@ end
|
|
|
14
14
|
When /^I background run "flapjack-worker"$/ do
|
|
15
15
|
@root = Pathname.new(File.dirname(__FILE__)).parent.parent.expand_path
|
|
16
16
|
bin_path = @root.join('bin')
|
|
17
|
-
command = "#{bin_path}/flapjack-worker 2>&1"
|
|
17
|
+
command = "ruby -rubygems #{bin_path}/flapjack-worker 2>&1"
|
|
18
18
|
|
|
19
|
-
@worker =
|
|
19
|
+
@worker = spawn_daemon(command)
|
|
20
20
|
|
|
21
21
|
sleep 1
|
|
22
|
-
|
|
23
|
-
at_exit do
|
|
24
|
-
Process.kill("KILL", @worker.pid)
|
|
25
|
-
end
|
|
26
22
|
end
|
|
27
23
|
|
|
28
24
|
Then /^I should see "([^"]*)" in the "([^"]*)" output$/ do |string, command|
|
|
@@ -59,3 +55,14 @@ end
|
|
|
59
55
|
When /^I sleep "(\d+)" seconds$/ do |time|
|
|
60
56
|
sleep(time.to_i)
|
|
61
57
|
end
|
|
58
|
+
|
|
59
|
+
When /^I insert a check onto the beanstalk$/ do
|
|
60
|
+
@queue = Beanstalk::Connection.new('localhost:11300', 'checks')
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
pending # express the regexp above with the code you wish you had
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
Then /^I should see a job on the "([^"]*)" beanstalk queue$/ do |arg1|
|
|
67
|
+
pending # express the regexp above with the code you wish you had
|
|
68
|
+
end
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
|
|
2
|
+
include Mail::Matchers
|
|
3
|
+
|
|
4
|
+
# copied from flapjack-populator
|
|
5
|
+
def add_contact(contact = {})
|
|
6
|
+
@redis.multi
|
|
7
|
+
@redis.del("contact:#{contact['id']}")
|
|
8
|
+
@redis.del("contact_media:#{contact['id']}")
|
|
9
|
+
@redis.hset("contact:#{contact['id']}", 'first_name', contact['first_name'])
|
|
10
|
+
@redis.hset("contact:#{contact['id']}", 'last_name', contact['last_name'])
|
|
11
|
+
@redis.hset("contact:#{contact['id']}", 'email', contact['email'])
|
|
12
|
+
contact['media'].each_pair {|medium, address|
|
|
13
|
+
@redis.hset("contact_media:#{contact['id']}", medium, address)
|
|
14
|
+
}
|
|
15
|
+
@redis.exec
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
Given /^the user wants to receive SMS notifications for entity '([\w\.\-]+)'$/ do |entity|
|
|
19
|
+
add_contact( 'id' => '0999',
|
|
20
|
+
'first_name' => 'John',
|
|
21
|
+
'last_name' => 'Smith',
|
|
22
|
+
'email' => 'johns@example.dom',
|
|
23
|
+
'media' => {'sms' => '+61888888888'} )
|
|
24
|
+
Flapjack::Data::Entity.add({'id' => '5000',
|
|
25
|
+
'name' => entity,
|
|
26
|
+
'contacts' => ["0999"]},
|
|
27
|
+
:redis => @redis )
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
Given /^the user wants to receive email notifications for entity '([\w\.\-]+)'$/ do |entity|
|
|
31
|
+
add_contact( 'id' => '0999',
|
|
32
|
+
'first_name' => 'John',
|
|
33
|
+
'last_name' => 'Smith',
|
|
34
|
+
'email' => 'johns@example.dom',
|
|
35
|
+
'media' => {'email' => 'johns@example.dom'} )
|
|
36
|
+
Flapjack::Data::Entity.add({'id' => '5000',
|
|
37
|
+
'name' => entity,
|
|
38
|
+
'contacts' => ["0999"]},
|
|
39
|
+
:redis => @redis )
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
Given /^the user wants to receive SMS notifications for entity '([\w\.\-]+)' and email notifications for entity '([\w\.\-]+)'$/ do |entity1, entity2|
|
|
43
|
+
add_contact( 'id' => '0998',
|
|
44
|
+
'first_name' => 'John',
|
|
45
|
+
'last_name' => 'Smith',
|
|
46
|
+
'email' => 'johns@example.dom',
|
|
47
|
+
'media' => {'sms' => '+61888888888'} )
|
|
48
|
+
add_contact( 'id' => '0999',
|
|
49
|
+
'first_name' => 'John',
|
|
50
|
+
'last_name' => 'Smith',
|
|
51
|
+
'email' => 'johns@example.dom',
|
|
52
|
+
'media' => {'email' => 'johns@example.dom'} )
|
|
53
|
+
Flapjack::Data::Entity.add({'id' => '5000',
|
|
54
|
+
'name' => entity1,
|
|
55
|
+
'contacts' => ["0998"]},
|
|
56
|
+
:redis => @redis )
|
|
57
|
+
Flapjack::Data::Entity.add({'id' => '5001',
|
|
58
|
+
'name' => entity2,
|
|
59
|
+
'contacts' => ["0999"]},
|
|
60
|
+
:redis => @redis )
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
When /^an event notification is generated for entity '([\w\.\-]+)'$/ do |entity|
|
|
64
|
+
event = Flapjack::Data::Event.new('type' => 'service',
|
|
65
|
+
'state' => 'critical',
|
|
66
|
+
'summary' => '100% packet loss',
|
|
67
|
+
'entity' => entity,
|
|
68
|
+
'check' => 'ping')
|
|
69
|
+
entity_check = Flapjack::Data::EntityCheck.for_entity_name(entity, 'ping', :redis => @redis)
|
|
70
|
+
@app.send(:generate_notification, event, entity_check)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
Then /^an SMS notification for entity '([\w\.\-]+)' should be queued for the user$/ do |entity|
|
|
74
|
+
queue = ResqueSpec.peek('sms_notifications')
|
|
75
|
+
queue.select {|n| n[:args].first['event_id'] =~ /#{entity}:ping/ }.should_not be_empty
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
Then /^an email notification for entity '([\w\.\-]+)' should be queued for the user$/ do |entity|
|
|
79
|
+
queue = ResqueSpec.peek('email_notifications')
|
|
80
|
+
queue.select {|n| n[:args].first['event_id'] =~ /#{entity}:ping/ }.should_not be_empty
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
Then /^an SMS notification for entity '([\w\.\-]+)' should not be queued for the user$/ do |entity|
|
|
84
|
+
queue = ResqueSpec.peek('sms_notifications')
|
|
85
|
+
queue.select {|n| n[:args].first['event_id'] =~ /#{entity}:ping/ }.should be_empty
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
Then /^an email notification for entity '([\w\.\-]+)' should not be queued for the user$/ do |entity|
|
|
89
|
+
queue = ResqueSpec.peek('email_notifications')
|
|
90
|
+
queue.select {|n| n[:args].first['event_id'] =~ /#{entity}:ping/ }.should be_empty
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
Given /^a user SMS notification has been queued for entity '([\w\.\-]+)'$/ do |entity|
|
|
94
|
+
Flapjack::Data::Entity.add({'id' => '5000',
|
|
95
|
+
'name' => entity},
|
|
96
|
+
:redis => @redis )
|
|
97
|
+
@sms_notification = {'notification_type' => 'problem',
|
|
98
|
+
'contact_first_name' => 'John',
|
|
99
|
+
'contact_last_name' => 'Smith',
|
|
100
|
+
'state' => 'CRITICAL',
|
|
101
|
+
'summary' => 'Socket timeout after 10 seconds',
|
|
102
|
+
'time' => Time.now.to_i,
|
|
103
|
+
'event_id' => "#{entity}:ping",
|
|
104
|
+
'address' => '+61412345678',
|
|
105
|
+
'id' => 1}
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
Given /^a user email notification has been queued for entity '([\w\.\-]+)'$/ do |entity|
|
|
109
|
+
Flapjack::Data::Entity.add({'id' => '5001',
|
|
110
|
+
'name' => entity},
|
|
111
|
+
:redis => @redis )
|
|
112
|
+
@email_notification = {'notification_type' => 'problem',
|
|
113
|
+
'contact_first_name' => 'John',
|
|
114
|
+
'contact_last_name' => 'Smith',
|
|
115
|
+
'state' => 'CRITICAL',
|
|
116
|
+
'summary' => 'Socket timeout after 10 seconds',
|
|
117
|
+
'time' => Time.now.to_i,
|
|
118
|
+
'event_id' => "#{entity}:ping",
|
|
119
|
+
'address' => 'johns@example.dom',
|
|
120
|
+
'id' => 2}
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
# NB using perform, the notifiers were accessing the wrong Redis DB number
|
|
124
|
+
|
|
125
|
+
# TODO may need to get more complex, depending which SMS provider is used
|
|
126
|
+
When /^the SMS notification handler runs successfully$/ do
|
|
127
|
+
# returns success by default - currently matches all addresses, maybe load from config?
|
|
128
|
+
stub_request(:get, /.*/)
|
|
129
|
+
# TODO load config from cfg file instead?
|
|
130
|
+
Flapjack::Notification::Sms.class_variable_set('@@config', {'username' => 'abcd', 'password' => 'efgh'})
|
|
131
|
+
|
|
132
|
+
lambda {
|
|
133
|
+
Flapjack::Notification::Sms.dispatch(@sms_notification, :logger => @logger, :redis => @redis)
|
|
134
|
+
}.should_not raise_error
|
|
135
|
+
@sms_sent = true
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
When /^the SMS notification handler fails to send an SMS$/ do
|
|
139
|
+
stub_request(:any, /.*/).to_return(:status => [500, "Internal Server Error"])
|
|
140
|
+
|
|
141
|
+
lambda {
|
|
142
|
+
Flapjack::Notification::Sms.dispatch(@sms_notification, :logger => @logger, :redis => @redis)
|
|
143
|
+
}.should raise_error
|
|
144
|
+
@sms_sent = false
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
When /^the email notification handler runs successfully$/ do
|
|
148
|
+
lambda {
|
|
149
|
+
Flapjack::Notification::Email.dispatch(@email_notification, :logger => @logger, :redis => @redis)
|
|
150
|
+
}.should_not raise_error
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
# This doesn't work as I have it here -- sends a mail with an empty To: header instead.
|
|
154
|
+
# Might have to introduce Rspec's stubs here to fake bad mailer behaviour -- or if mail sending
|
|
155
|
+
# won't ever fail, don't test for failure?
|
|
156
|
+
When /^the email notification handler fails to send an email$/ do
|
|
157
|
+
pending
|
|
158
|
+
lambda {
|
|
159
|
+
@email_notification['address'] = nil
|
|
160
|
+
Flapjack::Notification::Email.dispatch(@email_notification, :logger => @logger, :redis => @redis)
|
|
161
|
+
}.should_not raise_error
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
Then /^the user should receive an SMS notification$/ do
|
|
165
|
+
@sms_sent.should be_true
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
Then /^the user should receive an email notification$/ do
|
|
169
|
+
have_sent_email.should be_true
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
Then /^the user should not receive an SMS notification$/ do
|
|
173
|
+
@sms_sent.should be_false
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
Then /^the user should not receive an email notification$/ do
|
|
177
|
+
have_sent_email.should be_false
|
|
178
|
+
end
|
|
@@ -11,3 +11,17 @@ Then /^every file in the output should start with "([^\"]*)"$/ do |string|
|
|
|
11
11
|
`head -n 1 #{file}`.should =~ /^#{string}\s*$/
|
|
12
12
|
end
|
|
13
13
|
end
|
|
14
|
+
|
|
15
|
+
When /^I run "([^"]*)"$/ do |cmd|
|
|
16
|
+
#bin_path = '/usr/bin'
|
|
17
|
+
#command = "#{bin_path}/#{cmd}"
|
|
18
|
+
|
|
19
|
+
#@output = `#{command}`
|
|
20
|
+
@output = `#{cmd} 2>&1`
|
|
21
|
+
@exit_status = $?.exitstatus
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
Then /^the exit status should be (\d+)$/ do |number|
|
|
25
|
+
@exit_status.should == number.to_i
|
|
26
|
+
end
|
|
27
|
+
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require 'delorean'
|
|
4
|
+
require 'chronic'
|
|
5
|
+
|
|
6
|
+
When /^(.+) passes$/ do |time|
|
|
7
|
+
period = Chronic.parse("#{time} from now")
|
|
8
|
+
Delorean.time_travel_to(period)
|
|
9
|
+
puts "Time Travelled to #{Time.now.to_s}"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
Given /^I time travel to (.+)$/ do |period|
|
|
13
|
+
Delorean.time_travel_to(period)
|
|
14
|
+
puts "Time Travelled to #{Time.now.to_s}"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
Given /^I come back to the present$/ do
|
|
18
|
+
Delorean.back_to_the_present
|
|
19
|
+
puts "Time Travelled to the present, #{Time.now.to_s}"
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
Given /^I time travel in (.+) to (.+)$/ do |zone_name, timestamp|
|
|
23
|
+
zone = ::Time.find_zone!(zone_name)
|
|
24
|
+
time = zone.parse timestamp
|
|
25
|
+
Delorean.time_travel_to time
|
|
26
|
+
puts "Time Travelled to #{Time.now.to_s}"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
Then /^the time in UTC should be about (.+)$/ do |timestamp|
|
|
30
|
+
actual = Time.now.in_time_zone('UTC')
|
|
31
|
+
expected = Time.parse("#{timestamp} UTC")
|
|
32
|
+
(expected..expected+5).cover?(actual).should be_true
|
|
33
|
+
end
|
|
34
|
+
|
data/features/support/env.rb
CHANGED
|
@@ -1,51 +1,78 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
|
|
3
|
+
if ENV['COVERAGE']
|
|
4
|
+
require 'simplecov'
|
|
5
|
+
SimpleCov.start do
|
|
6
|
+
add_filter '/features/'
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
ENV["FLAPJACK_ENV"] = 'test'
|
|
11
|
+
require 'bundler'
|
|
12
|
+
Bundler.require(:default, :test)
|
|
13
|
+
|
|
3
14
|
$: << File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib'))
|
|
4
15
|
|
|
5
16
|
require 'pathname'
|
|
6
|
-
|
|
7
|
-
require '
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
|
|
18
|
+
require 'webmock/cucumber'
|
|
19
|
+
WebMock.disable_net_connect!
|
|
20
|
+
|
|
21
|
+
require 'flapjack/executive'
|
|
22
|
+
require 'flapjack/patches'
|
|
23
|
+
|
|
24
|
+
class MockLogger
|
|
25
|
+
attr_accessor :messages
|
|
26
|
+
|
|
27
|
+
def initialize
|
|
28
|
+
@messages = []
|
|
16
29
|
end
|
|
17
30
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
#
|
|
23
|
-
# http://weblog.jamisbuck.org/assets/2006/9/25/gdb.rb
|
|
24
|
-
def read_until_timeout(pipe, timeout=1, verbose=false)
|
|
25
|
-
output = []
|
|
26
|
-
line = ""
|
|
27
|
-
while data = IO.select([pipe], nil, nil, timeout) do
|
|
28
|
-
next if data.empty?
|
|
29
|
-
char = pipe.read(1)
|
|
30
|
-
break if char.nil?
|
|
31
|
-
|
|
32
|
-
line << char
|
|
33
|
-
if line[-1] == ?\n
|
|
34
|
-
puts line if verbose
|
|
35
|
-
output << line
|
|
36
|
-
line = ""
|
|
31
|
+
%w(debug info warn error fatal).each do |level|
|
|
32
|
+
class_eval <<-RUBY
|
|
33
|
+
def #{level}(msg)
|
|
34
|
+
@messages << msg
|
|
37
35
|
end
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
output
|
|
36
|
+
RUBY
|
|
41
37
|
end
|
|
38
|
+
end
|
|
42
39
|
|
|
40
|
+
Mail.defaults do
|
|
41
|
+
delivery_method :test
|
|
43
42
|
end
|
|
44
43
|
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
redis_opts = { :db => 14, :driver => :ruby }
|
|
45
|
+
redis = ::Redis.new(redis_opts)
|
|
46
|
+
redis.flushdb
|
|
47
|
+
redis.quit
|
|
48
|
+
|
|
49
|
+
Before do
|
|
50
|
+
@logger = MockLogger.new
|
|
51
|
+
# Use a separate database whilst testing
|
|
52
|
+
@app = Flapjack::Executive.new
|
|
53
|
+
@app.bootstrap(:logger => @logger, :redis => redis_opts,
|
|
54
|
+
:config => {'email_queue' => 'email_notifications',
|
|
55
|
+
'sms_queue' => 'sms_notifications'})
|
|
56
|
+
@app.setup
|
|
57
|
+
@redis = @app.redis
|
|
47
58
|
end
|
|
48
59
|
|
|
49
|
-
|
|
50
|
-
|
|
60
|
+
After do
|
|
61
|
+
@redis.flushdb
|
|
62
|
+
@redis.quit
|
|
63
|
+
# Reset the logged messages
|
|
64
|
+
@logger.messages = []
|
|
51
65
|
end
|
|
66
|
+
|
|
67
|
+
Before('@resque') do
|
|
68
|
+
ResqueSpec.reset!
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
Before('@email') do
|
|
72
|
+
Mail::TestMailer.deliveries.clear
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
After('@time') do
|
|
76
|
+
Delorean.back_to_the_present
|
|
77
|
+
end
|
|
78
|
+
|
data/flapjack.gemspec
CHANGED
|
@@ -1,192 +1,41 @@
|
|
|
1
|
-
# Generated by jeweler
|
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
|
4
1
|
# -*- encoding: utf-8 -*-
|
|
2
|
+
require File.expand_path('../lib/flapjack/version', __FILE__)
|
|
5
3
|
|
|
6
|
-
Gem::Specification.new do |
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
Gem::Specification.new do |gem|
|
|
5
|
+
gem.authors = ["Lindsay Holmwood"]
|
|
6
|
+
gem.email = %q{lindsay@holmwood.id.au}
|
|
7
|
+
gem.description = %q{Flapjack is highly scalable and distributed monitoring system. It understands the Nagios plugin format, and can easily be scaled from 1 server to 1000.}
|
|
8
|
+
gem.summary = %q{a scalable and distributed monitoring system}
|
|
9
|
+
gem.homepage = %q{http://flapjack-project.com/}
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
]
|
|
19
|
-
s.files = [
|
|
20
|
-
".gitignore",
|
|
21
|
-
"LICENCE",
|
|
22
|
-
"README.md",
|
|
23
|
-
"Rakefile",
|
|
24
|
-
"TODO.md",
|
|
25
|
-
"VERSION",
|
|
26
|
-
"bin/flapjack-benchmark",
|
|
27
|
-
"bin/flapjack-netsaint-parser",
|
|
28
|
-
"bin/flapjack-notifier",
|
|
29
|
-
"bin/flapjack-notifier-manager",
|
|
30
|
-
"bin/flapjack-populator",
|
|
31
|
-
"bin/flapjack-stats",
|
|
32
|
-
"bin/flapjack-worker",
|
|
33
|
-
"bin/flapjack-worker-manager",
|
|
34
|
-
"bin/install-flapjack-systemwide",
|
|
35
|
-
"dist/etc/default/flapjack-notifier",
|
|
36
|
-
"dist/etc/default/flapjack-workers",
|
|
37
|
-
"dist/etc/flapjack/flapjack-notifier.conf.example",
|
|
38
|
-
"dist/etc/flapjack/recipients.conf.example",
|
|
39
|
-
"dist/etc/init.d/flapjack-notifier",
|
|
40
|
-
"dist/etc/init.d/flapjack-workers",
|
|
41
|
-
"dist/puppet/flapjack/files/.stub",
|
|
42
|
-
"dist/puppet/flapjack/manifests/common.pp",
|
|
43
|
-
"dist/puppet/flapjack/manifests/notifier.pp",
|
|
44
|
-
"dist/puppet/flapjack/manifests/worker.pp",
|
|
45
|
-
"dist/puppet/flapjack/templates/.stub",
|
|
46
|
-
"dist/puppet/ruby/manifests/dev.pp",
|
|
47
|
-
"dist/puppet/ruby/manifests/rubygems.pp",
|
|
48
|
-
"dist/puppet/sqlite3/manifests/dev.pp",
|
|
49
|
-
"doc/CONFIGURING.md",
|
|
50
|
-
"doc/DEVELOPING.md",
|
|
51
|
-
"doc/INSTALL.md",
|
|
52
|
-
"doc/PACKAGING.md",
|
|
53
|
-
"features/flapjack-notifier-manager.feature",
|
|
54
|
-
"features/flapjack-worker-manager.feature",
|
|
55
|
-
"features/flapjack-worker.feature",
|
|
56
|
-
"features/netsaint-config-converter.feature",
|
|
57
|
-
"features/packaging-lintian.feature",
|
|
58
|
-
"features/persistence/couch.feature",
|
|
59
|
-
"features/persistence/sqlite3.feature",
|
|
60
|
-
"features/persistence/steps/couch_steps.rb",
|
|
61
|
-
"features/persistence/steps/generic_steps.rb",
|
|
62
|
-
"features/persistence/steps/sqlite3_steps.rb",
|
|
63
|
-
"features/steps/flapjack-importer_steps.rb",
|
|
64
|
-
"features/steps/flapjack-netsaint-parser_steps.rb",
|
|
65
|
-
"features/steps/flapjack-notifier-manager_steps.rb",
|
|
66
|
-
"features/steps/flapjack-worker-manager_steps.rb",
|
|
67
|
-
"features/steps/flapjack-worker_steps.rb",
|
|
68
|
-
"features/steps/packaging-lintian_steps.rb",
|
|
69
|
-
"features/support/env.rb",
|
|
70
|
-
"features/support/silent_system.rb",
|
|
71
|
-
"features/support/tmp/.stub",
|
|
72
|
-
"flapjack.gemspec",
|
|
73
|
-
"lib/flapjack.rb",
|
|
74
|
-
"lib/flapjack/applications/notifier.rb",
|
|
75
|
-
"lib/flapjack/applications/worker.rb",
|
|
76
|
-
"lib/flapjack/checks/http_content",
|
|
77
|
-
"lib/flapjack/checks/ping",
|
|
78
|
-
"lib/flapjack/cli/notifier.rb",
|
|
79
|
-
"lib/flapjack/cli/notifier_manager.rb",
|
|
80
|
-
"lib/flapjack/cli/worker.rb",
|
|
81
|
-
"lib/flapjack/cli/worker_manager.rb",
|
|
82
|
-
"lib/flapjack/filters/any_parents_failed.rb",
|
|
83
|
-
"lib/flapjack/filters/ok.rb",
|
|
84
|
-
"lib/flapjack/inifile.rb",
|
|
85
|
-
"lib/flapjack/notifier_engine.rb",
|
|
86
|
-
"lib/flapjack/notifiers/mailer/init.rb",
|
|
87
|
-
"lib/flapjack/notifiers/mailer/mailer.rb",
|
|
88
|
-
"lib/flapjack/notifiers/xmpp/init.rb",
|
|
89
|
-
"lib/flapjack/notifiers/xmpp/xmpp.rb",
|
|
90
|
-
"lib/flapjack/patches.rb",
|
|
91
|
-
"lib/flapjack/persistence/couch.rb",
|
|
92
|
-
"lib/flapjack/persistence/couch/connection.rb",
|
|
93
|
-
"lib/flapjack/persistence/couch/couch.rb",
|
|
94
|
-
"lib/flapjack/persistence/data_mapper.rb",
|
|
95
|
-
"lib/flapjack/persistence/data_mapper/data_mapper.rb",
|
|
96
|
-
"lib/flapjack/persistence/data_mapper/models/check.rb",
|
|
97
|
-
"lib/flapjack/persistence/data_mapper/models/check_template.rb",
|
|
98
|
-
"lib/flapjack/persistence/data_mapper/models/event.rb",
|
|
99
|
-
"lib/flapjack/persistence/data_mapper/models/node.rb",
|
|
100
|
-
"lib/flapjack/persistence/data_mapper/models/related_check.rb",
|
|
101
|
-
"lib/flapjack/persistence/sqlite3.rb",
|
|
102
|
-
"lib/flapjack/persistence/sqlite3/sqlite3.rb",
|
|
103
|
-
"lib/flapjack/transports/beanstalkd.rb",
|
|
104
|
-
"lib/flapjack/transports/result.rb",
|
|
105
|
-
"spec/check_sandbox/echo",
|
|
106
|
-
"spec/check_sandbox/sandboxed_check",
|
|
107
|
-
"spec/configs/flapjack-notifier-couchdb.ini",
|
|
108
|
-
"spec/configs/flapjack-notifier.ini",
|
|
109
|
-
"spec/configs/recipients.ini",
|
|
110
|
-
"spec/helpers.rb",
|
|
111
|
-
"spec/inifile_spec.rb",
|
|
112
|
-
"spec/mock-notifiers/mock/init.rb",
|
|
113
|
-
"spec/mock-notifiers/mock/mock.rb",
|
|
114
|
-
"spec/notifier-directories/spoons/testmailer/init.rb",
|
|
115
|
-
"spec/notifier_application_spec.rb",
|
|
116
|
-
"spec/notifier_filters_spec.rb",
|
|
117
|
-
"spec/notifier_options_multiplexer_spec.rb",
|
|
118
|
-
"spec/notifier_options_spec.rb",
|
|
119
|
-
"spec/notifier_spec.rb",
|
|
120
|
-
"spec/notifiers/mailer_spec.rb",
|
|
121
|
-
"spec/notifiers/xmpp_spec.rb",
|
|
122
|
-
"spec/persistence/datamapper_spec.rb",
|
|
123
|
-
"spec/persistence/mock_persistence_backend.rb",
|
|
124
|
-
"spec/simple.ini",
|
|
125
|
-
"spec/spec.opts",
|
|
126
|
-
"spec/test-filters/blocker.rb",
|
|
127
|
-
"spec/test-filters/mock.rb",
|
|
128
|
-
"spec/transports/beanstalkd_spec.rb",
|
|
129
|
-
"spec/transports/mock_transport.rb",
|
|
130
|
-
"spec/worker_application_spec.rb",
|
|
131
|
-
"spec/worker_options_spec.rb"
|
|
132
|
-
]
|
|
133
|
-
s.homepage = %q{http://flapjack-project.com/}
|
|
134
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
|
135
|
-
s.require_paths = ["lib"]
|
|
136
|
-
s.rubygems_version = %q{1.3.7}
|
|
137
|
-
s.summary = %q{a scalable and distributed monitoring system}
|
|
138
|
-
s.test_files = [
|
|
139
|
-
"spec/helpers.rb",
|
|
140
|
-
"spec/inifile_spec.rb",
|
|
141
|
-
"spec/mock-notifiers/mock/init.rb",
|
|
142
|
-
"spec/mock-notifiers/mock/mock.rb",
|
|
143
|
-
"spec/notifier-directories/spoons/testmailer/init.rb",
|
|
144
|
-
"spec/notifier_application_spec.rb",
|
|
145
|
-
"spec/notifier_filters_spec.rb",
|
|
146
|
-
"spec/notifier_options_multiplexer_spec.rb",
|
|
147
|
-
"spec/notifier_options_spec.rb",
|
|
148
|
-
"spec/notifier_spec.rb",
|
|
149
|
-
"spec/notifiers/mailer_spec.rb",
|
|
150
|
-
"spec/notifiers/xmpp_spec.rb",
|
|
151
|
-
"spec/persistence/datamapper_spec.rb",
|
|
152
|
-
"spec/persistence/mock_persistence_backend.rb",
|
|
153
|
-
"spec/test-filters/blocker.rb",
|
|
154
|
-
"spec/test-filters/mock.rb",
|
|
155
|
-
"spec/transports/beanstalkd_spec.rb",
|
|
156
|
-
"spec/transports/mock_transport.rb",
|
|
157
|
-
"spec/worker_application_spec.rb",
|
|
158
|
-
"spec/worker_options_spec.rb"
|
|
159
|
-
]
|
|
11
|
+
# see http://yehudakatz.com/2010/12/16/clarifying-the-roles-of-the-gemspec-and-gemfile/
|
|
12
|
+
# following a middle road here, not shipping it with the gem :)
|
|
13
|
+
gem.files = `git ls-files`.split($\) - ['Gemfile.lock', 'bin/flapjack-bpimport']
|
|
14
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
|
15
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
|
16
|
+
gem.name = "flapjack"
|
|
17
|
+
gem.require_paths = ["lib"]
|
|
18
|
+
gem.version = Flapjack::VERSION
|
|
160
19
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
20
|
+
gem.add_dependency 'daemons'
|
|
21
|
+
gem.add_dependency 'log4r'
|
|
22
|
+
gem.add_dependency 'yajl-ruby'
|
|
23
|
+
gem.add_dependency 'eventmachine', '~> 1.0.0'
|
|
24
|
+
gem.add_dependency 'hiredis'
|
|
25
|
+
gem.add_dependency 'em-synchrony', '~> 1.0.2'
|
|
26
|
+
gem.add_dependency 'em-http-request'
|
|
27
|
+
gem.add_dependency 'redis'
|
|
28
|
+
gem.add_dependency 'em-resque'
|
|
29
|
+
gem.add_dependency 'sinatra'
|
|
30
|
+
gem.add_dependency 'rack-fiber_pool'
|
|
31
|
+
gem.add_dependency 'haml'
|
|
32
|
+
gem.add_dependency 'thin'
|
|
33
|
+
gem.add_dependency 'mail'
|
|
34
|
+
gem.add_dependency 'blather'
|
|
35
|
+
gem.add_dependency 'chronic'
|
|
36
|
+
gem.add_dependency 'chronic_duration'
|
|
37
|
+
gem.add_dependency 'httparty'
|
|
164
38
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
s.add_runtime_dependency(%q<beanstalk-client>, ["= 1.0.2"])
|
|
168
|
-
s.add_runtime_dependency(%q<log4r>, ["= 1.1.5"])
|
|
169
|
-
s.add_runtime_dependency(%q<xmpp4r>, ["= 0.5"])
|
|
170
|
-
s.add_runtime_dependency(%q<tmail>, ["= 1.2.3.1"])
|
|
171
|
-
s.add_runtime_dependency(%q<yajl-ruby>, ["= 0.6.4"])
|
|
172
|
-
s.add_runtime_dependency(%q<sqlite3-ruby>, ["= 1.2.5"])
|
|
173
|
-
else
|
|
174
|
-
s.add_dependency(%q<daemons>, ["= 1.0.10"])
|
|
175
|
-
s.add_dependency(%q<beanstalk-client>, ["= 1.0.2"])
|
|
176
|
-
s.add_dependency(%q<log4r>, ["= 1.1.5"])
|
|
177
|
-
s.add_dependency(%q<xmpp4r>, ["= 0.5"])
|
|
178
|
-
s.add_dependency(%q<tmail>, ["= 1.2.3.1"])
|
|
179
|
-
s.add_dependency(%q<yajl-ruby>, ["= 0.6.4"])
|
|
180
|
-
s.add_dependency(%q<sqlite3-ruby>, ["= 1.2.5"])
|
|
181
|
-
end
|
|
182
|
-
else
|
|
183
|
-
s.add_dependency(%q<daemons>, ["= 1.0.10"])
|
|
184
|
-
s.add_dependency(%q<beanstalk-client>, ["= 1.0.2"])
|
|
185
|
-
s.add_dependency(%q<log4r>, ["= 1.1.5"])
|
|
186
|
-
s.add_dependency(%q<xmpp4r>, ["= 0.5"])
|
|
187
|
-
s.add_dependency(%q<tmail>, ["= 1.2.3.1"])
|
|
188
|
-
s.add_dependency(%q<yajl-ruby>, ["= 0.6.4"])
|
|
189
|
-
s.add_dependency(%q<sqlite3-ruby>, ["= 1.2.5"])
|
|
190
|
-
end
|
|
39
|
+
gem.add_development_dependency 'rake'
|
|
40
|
+
gem.add_development_dependency 'colorize'
|
|
191
41
|
end
|
|
192
|
-
|