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.
Files changed (167) hide show
  1. data/.gitignore +10 -0
  2. data/.rbenv-version +1 -0
  3. data/.rspec +10 -0
  4. data/Gemfile +18 -0
  5. data/Guardfile +14 -0
  6. data/README.md +152 -173
  7. data/Rakefile +53 -150
  8. data/bin/flapjack +72 -0
  9. data/bin/flapjack-nagios-receiver +111 -0
  10. data/bin/flapjack-nagios-receiver-control +15 -0
  11. data/bin/flapjack-netsaint-parser +0 -2
  12. data/bin/flapjack-populator +133 -16
  13. data/bin/install-flapjack-systemwide +2 -2
  14. data/config.ru +11 -0
  15. data/dist/etc/init.d/flapjack +46 -0
  16. data/dist/etc/init.d/flapjack-nagios-receiver +36 -0
  17. data/doc/GLOSSARY.md +19 -0
  18. data/etc/flapjack_config.yaml.example +90 -0
  19. data/features/events.feature +132 -0
  20. data/features/notifications.feature +57 -0
  21. data/features/packaging-lintian.feature +5 -3
  22. data/features/steps/events_steps.rb +164 -0
  23. data/features/steps/flapjack-importer_steps.rb +2 -5
  24. data/features/steps/flapjack-worker_steps.rb +13 -6
  25. data/features/steps/notifications_steps.rb +178 -0
  26. data/features/steps/packaging-lintian_steps.rb +14 -0
  27. data/features/steps/time_travel_steps.rb +34 -0
  28. data/features/support/env.rb +63 -36
  29. data/flapjack.gemspec +35 -186
  30. data/lib/flapjack.rb +2 -0
  31. data/lib/flapjack/api.rb +274 -0
  32. data/lib/flapjack/api/entity_check_presenter.rb +184 -0
  33. data/lib/flapjack/api/entity_presenter.rb +66 -0
  34. data/lib/flapjack/cli/worker_manager.rb +1 -2
  35. data/lib/flapjack/configuration.rb +11 -0
  36. data/lib/flapjack/coordinator.rb +288 -0
  37. data/lib/flapjack/daemonizing.rb +186 -0
  38. data/lib/flapjack/data/contact.rb +45 -0
  39. data/lib/flapjack/data/entity.rb +89 -0
  40. data/lib/flapjack/data/entity_check.rb +396 -0
  41. data/lib/flapjack/data/event.rb +144 -0
  42. data/lib/flapjack/data/notification.rb +13 -0
  43. data/lib/flapjack/executive.rb +289 -0
  44. data/lib/flapjack/filters/acknowledgement.rb +39 -0
  45. data/lib/flapjack/filters/{any_parents_failed.rb → base.rb} +6 -4
  46. data/lib/flapjack/filters/delays.rb +53 -0
  47. data/lib/flapjack/filters/detect_mass_client_failures.rb +44 -0
  48. data/lib/flapjack/filters/ok.rb +25 -5
  49. data/lib/flapjack/filters/scheduled_maintenance.rb +17 -0
  50. data/lib/flapjack/filters/unscheduled_maintenance.rb +17 -0
  51. data/lib/flapjack/jabber.rb +294 -0
  52. data/lib/flapjack/notification/common.rb +23 -0
  53. data/lib/flapjack/notification/email.rb +107 -0
  54. data/lib/flapjack/notification/email/alert.html.haml +48 -0
  55. data/lib/flapjack/notification/email/alert.text.erb +14 -0
  56. data/lib/flapjack/notification/sms.rb +42 -0
  57. data/lib/flapjack/notification/sms/messagenet.rb +49 -0
  58. data/lib/flapjack/notifier_engine.rb +4 -4
  59. data/lib/flapjack/notifiers/mailer/mailer.rb +6 -7
  60. data/lib/flapjack/notifiers/xmpp/xmpp.rb +12 -12
  61. data/lib/flapjack/pagerduty.rb +230 -0
  62. data/lib/flapjack/patches.rb +108 -19
  63. data/lib/flapjack/persistence/data_mapper/models/check.rb +5 -3
  64. data/lib/flapjack/persistence/data_mapper/models/check_template.rb +2 -0
  65. data/lib/flapjack/persistence/data_mapper/models/event.rb +2 -0
  66. data/lib/flapjack/persistence/data_mapper/models/node.rb +3 -1
  67. data/lib/flapjack/persistence/data_mapper/models/related_check.rb +3 -1
  68. data/lib/flapjack/pikelet.rb +56 -0
  69. data/lib/flapjack/transports/beanstalkd.rb +1 -1
  70. data/lib/flapjack/transports/result.rb +6 -6
  71. data/lib/flapjack/utility.rb +46 -0
  72. data/lib/flapjack/version.rb +5 -0
  73. data/lib/flapjack/web.rb +198 -0
  74. data/lib/flapjack/web/views/acknowledge.haml +55 -0
  75. data/lib/flapjack/web/views/check.haml +162 -0
  76. data/lib/flapjack/web/views/index.haml +92 -0
  77. data/lib/flapjack/web/views/self_stats.haml +56 -0
  78. data/lib/flapjack/{applications/worker.rb → worker/application.rb} +0 -0
  79. data/lib/flapjack/worker/cli.rb +49 -0
  80. data/{spec → spec.old}/check_sandbox/echo +0 -0
  81. data/{spec → spec.old}/check_sandbox/sandboxed_check +0 -0
  82. data/{spec → spec.old}/configs/flapjack-notifier-couchdb.ini +0 -0
  83. data/{spec → spec.old}/configs/flapjack-notifier.ini +0 -0
  84. data/{spec → spec.old}/configs/recipients.ini +0 -0
  85. data/{spec → spec.old}/helpers.rb +0 -0
  86. data/{spec → spec.old}/inifile_spec.rb +0 -0
  87. data/{spec → spec.old}/mock-notifiers/mock/init.rb +0 -0
  88. data/{spec → spec.old}/mock-notifiers/mock/mock.rb +0 -0
  89. data/{spec → spec.old}/notifier-directories/spoons/testmailer/init.rb +0 -0
  90. data/{spec → spec.old}/notifier_application_spec.rb +0 -0
  91. data/{spec → spec.old}/notifier_filters_spec.rb +0 -0
  92. data/{spec → spec.old}/notifier_options_multiplexer_spec.rb +0 -0
  93. data/{spec → spec.old}/notifier_options_spec.rb +0 -0
  94. data/{spec → spec.old}/notifier_spec.rb +0 -0
  95. data/{spec → spec.old}/notifiers/mailer_spec.rb +0 -0
  96. data/{spec → spec.old}/notifiers/xmpp_spec.rb +0 -0
  97. data/{spec → spec.old}/persistence/datamapper_spec.rb +0 -0
  98. data/{spec → spec.old}/persistence/mock_persistence_backend.rb +0 -0
  99. data/{spec → spec.old}/simple.ini +0 -0
  100. data/{spec → spec.old}/spec.opts +0 -0
  101. data/{spec → spec.old}/test-filters/blocker.rb +0 -0
  102. data/{spec → spec.old}/test-filters/mock.rb +0 -0
  103. data/{spec → spec.old}/transports/beanstalkd_spec.rb +0 -0
  104. data/{spec → spec.old}/transports/mock_transport.rb +0 -0
  105. data/{spec → spec.old}/worker_application_spec.rb +0 -0
  106. data/{spec → spec.old}/worker_options_spec.rb +0 -0
  107. data/spec/lib/flapjack/api/entity_check_presenter_spec.rb +117 -0
  108. data/spec/lib/flapjack/api/entity_presenter_spec.rb +92 -0
  109. data/spec/lib/flapjack/api_spec.rb +170 -0
  110. data/spec/lib/flapjack/coordinator_spec.rb +16 -0
  111. data/spec/lib/flapjack/data/entity_check_spec.rb +398 -0
  112. data/spec/lib/flapjack/data/entity_spec.rb +71 -0
  113. data/spec/lib/flapjack/data/event_spec.rb +6 -0
  114. data/spec/lib/flapjack/executive_spec.rb +59 -0
  115. data/spec/lib/flapjack/filters/acknowledgement_spec.rb +6 -0
  116. data/spec/lib/flapjack/filters/delays_spec.rb +6 -0
  117. data/spec/lib/flapjack/filters/detect_mass_client_failures_spec.rb +6 -0
  118. data/spec/lib/flapjack/filters/ok_spec.rb +6 -0
  119. data/spec/lib/flapjack/filters/scheduled_maintenance_spec.rb +6 -0
  120. data/spec/lib/flapjack/filters/unscheduled_maintenance_spec.rb +6 -0
  121. data/spec/lib/flapjack/jabber_spec.rb +150 -0
  122. data/spec/lib/flapjack/notification/email_spec.rb +6 -0
  123. data/spec/lib/flapjack/notification/sms_spec.rb +6 -0
  124. data/spec/lib/flapjack/pikelet_spec.rb +28 -0
  125. data/spec/lib/flapjack/web_spec.rb +188 -0
  126. data/spec/spec_helper.rb +44 -0
  127. data/spec/support/profile_all_formatter.rb +44 -0
  128. data/spec/support/uncolored_doc_formatter.rb +9 -0
  129. data/tasks/events.rake +85 -0
  130. data/tmp/acknowledge.rb +14 -0
  131. data/tmp/create_config_yaml.rb +16 -0
  132. data/tmp/create_events_failure.rb +33 -0
  133. data/tmp/create_events_ok.rb +33 -0
  134. data/tmp/create_events_ok_fail_ack_ok.rb +54 -0
  135. data/tmp/create_events_ok_failure.rb +40 -0
  136. data/tmp/create_events_ok_failure_ack.rb +54 -0
  137. data/tmp/dummy_entities.json +1 -0
  138. data/tmp/generate_nagios_test_hosts.rb +16 -0
  139. data/tmp/parse_config_yaml.rb +7 -0
  140. data/tmp/redis_delete_all_keys.rb +11 -0
  141. data/tmp/test_entities.json +1 -0
  142. metadata +482 -221
  143. data/TODO.md +0 -36
  144. data/VERSION +0 -1
  145. data/bin/flapjack-benchmark +0 -50
  146. data/bin/flapjack-notifier +0 -21
  147. data/bin/flapjack-notifier-manager +0 -43
  148. data/bin/flapjack-stats +0 -27
  149. data/bin/flapjack-worker +0 -13
  150. data/bin/flapjack-worker-manager +0 -35
  151. data/dist/etc/init.d/flapjack-notifier +0 -47
  152. data/dist/etc/init.d/flapjack-workers +0 -44
  153. data/features/flapjack-notifier-manager.feature +0 -19
  154. data/features/flapjack-worker-manager.feature +0 -27
  155. data/features/flapjack-worker.feature +0 -27
  156. data/features/netsaint-config-converter.feature +0 -126
  157. data/features/persistence/couch.feature +0 -105
  158. data/features/persistence/sqlite3.feature +0 -105
  159. data/features/persistence/steps/couch_steps.rb +0 -25
  160. data/features/persistence/steps/generic_steps.rb +0 -102
  161. data/features/persistence/steps/sqlite3_steps.rb +0 -13
  162. data/features/steps/flapjack-notifier-manager_steps.rb +0 -24
  163. data/features/steps/flapjack-worker-manager_steps.rb +0 -48
  164. data/lib/flapjack/applications/notifier.rb +0 -222
  165. data/lib/flapjack/cli/notifier.rb +0 -108
  166. data/lib/flapjack/cli/notifier_manager.rb +0 -86
  167. data/lib/flapjack/cli/worker.rb +0 -51
@@ -1,108 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'ostruct'
4
- require 'optparse'
5
- require 'log4r'
6
- require 'log4r/outputter/syslogoutputter'
7
- require File.join(File.dirname(__FILE__), '..', 'inifile')
8
-
9
- module Flapjack
10
- module Notifier
11
- class Options
12
- def self.parse(args)
13
- options = OpenStruct.new
14
- opts = OptionParser.new do |opts|
15
- opts.on('-r', '--recipients FILE', 'recipients file') do |filename|
16
- options.recipients_filename = filename
17
- end
18
- opts.on('-c', '--config FILE', 'config file') do |filename|
19
- options.config_filename = filename
20
- end
21
- opts.on_tail("-h", "--help", "Show this message") do
22
- puts opts
23
- exit
24
- end
25
- end
26
-
27
- # parse the options
28
- begin
29
- opts.parse!(args)
30
- rescue OptionParser::MissingArgument => e
31
- # if an --option is missing it's argument
32
- puts e.message.capitalize + "\n\n"
33
- puts opts
34
- exit 1
35
- end
36
-
37
- # validation of command line arguments
38
- @errors = []
39
- # check that recipients file exists
40
- if options.recipients_filename
41
- unless File.exists?(options.recipients_filename)
42
- @errors << "The specified recipients file doesn't exist!"
43
- end
44
- else
45
- @errors << "You need to specify a recipients file with --recipients."
46
- end
47
-
48
- # check that config file exists
49
- if options.config_filename
50
- unless File.exists?(options.config_filename.to_s)
51
- @errors << "The specified config file doesn't exist!"
52
- end
53
- else
54
- options.config_filename = "/etc/flapjack/flapjack-notifier.conf"
55
- unless File.exists?(options.config_filename)
56
- @errors << "The default config file (#{options.config_filename}) doesn't exist."
57
- @errors << "Please set one up, or specify one with --config."
58
- end
59
- end
60
-
61
-
62
- # if there are errors, print them out and exit
63
- if @errors.size > 0
64
- puts "Errors:"
65
- @errors.each do |error|
66
- puts " - #{error}"
67
- end
68
- puts
69
- puts opts
70
- exit 2
71
- end
72
-
73
- # config loader
74
-
75
- # holder for transport + persistence config
76
- options.transport = OpenStruct.new
77
- options.persistence = OpenStruct.new
78
-
79
- config = Flapjack::Inifile.read(options.config_filename)
80
-
81
- %w(transport persistence).each do |backend|
82
- options.send("#{backend}=", config[backend].symbolize_keys)
83
- end
84
-
85
- # base config (config.blah)
86
- config['notifier'].each_pair do |key, value|
87
- normalised_key = key.gsub('-', '_')
88
- values = value.split(/,*\s+/)
89
- options.send("#{normalised_key}=", values)
90
- end
91
-
92
- # list of notifiers to load + their config
93
- notifiers_to_load = options.notifiers
94
- options.notifiers = {}
95
- notifiers_to_load.each do |notifier|
96
- options.notifiers[notifier] = config["#{notifier}-notifier"].symbolize_keys
97
- end
98
-
99
- # holder for recipients list
100
- recipients = Flapjack::Inifile.read(options.recipients_filename)
101
- options.recipients = recipients.all
102
-
103
- options
104
- end
105
- end
106
- end
107
-
108
- end
@@ -1,86 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'rubygems'
4
- require 'ostruct'
5
- require 'optparse'
6
-
7
- module Flapjack
8
- class NotifierManagerOptions
9
- def self.parse(args)
10
- options = OpenStruct.new
11
- opts = OptionParser.new do |opts|
12
- opts.banner = "Usage: flapjack-notifier-manager <command> [options]"
13
- opts.separator " "
14
- opts.separator " where <command> is one of:"
15
- opts.separator " start start a worker"
16
- opts.separator " stop stop all workers"
17
- opts.separator " restart restart workers"
18
- opts.separator " "
19
- opts.separator " and [options] are:"
20
-
21
- opts.on('-b', '--beanstalk HOST', 'location of the beanstalkd') do |host|
22
- options.host = host
23
- end
24
- opts.on('-p', '--port PORT', 'beanstalkd port') do |port|
25
- options.port = port.to_s
26
- end
27
- opts.on('-r', '--recipients FILE', 'recipients file') do |recipients|
28
- options.recipients = File.expand_path(recipients.to_s)
29
- end
30
- opts.on('-c', '--config FILE', 'config file') do |config|
31
- options.config_filename = config.to_s
32
- end
33
- end
34
-
35
- begin
36
- opts.parse!(args)
37
- rescue => e
38
- puts e.message.capitalize + "\n\n"
39
- puts opts
40
- exit 1
41
- end
42
-
43
- # defaults
44
- options.host ||= "localhost"
45
- options.port ||= 11300
46
-
47
- @errors = []
48
-
49
- unless ARGV[0] == "stop"
50
- if options.recipients
51
- unless File.exists?(options.recipients)
52
- @errors << "The specified recipients file doesn't exist!"
53
- end
54
- else
55
- @errors << "You must specify a recipients file!"
56
- end
57
-
58
- if options.config_filename
59
- unless File.exists?(options.config_filename)
60
- @errors << "The specified config file dosen't exist!"
61
- end
62
- else
63
- @errors << "You must specify a config file!"
64
- end
65
- end
66
-
67
- if @errors.size > 0
68
- puts "Errors:"
69
- @errors.each do |error|
70
- puts " - #{error}"
71
- end
72
- puts
73
- puts opts
74
- exit 2
75
- end
76
-
77
- unless %w(start stop restart).include?(args[0])
78
- puts opts
79
- exit 1
80
- end
81
-
82
- options
83
- end
84
- end
85
-
86
- end
@@ -1,51 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'rubygems'
4
- require 'beanstalk-client'
5
- require 'ostruct'
6
- require 'optparse'
7
- require 'log4r'
8
- require 'log4r/outputter/syslogoutputter'
9
- require 'flapjack/patches'
10
-
11
- module Flapjack
12
- class WorkerOptions
13
- def self.parse(args)
14
- options = OpenStruct.new
15
- opts = OptionParser.new do |opts|
16
- # the available command line options
17
- opts.on('-b', '--beanstalk HOST', 'location of the beanstalkd') do |host|
18
- options.host = host
19
- end
20
- opts.on('-p', '--port PORT', 'beanstalkd port') do |port|
21
- options.port = port.to_i
22
- end
23
- opts.on('-c', '--checks-directory DIR', 'sandboxed check directory') do |dir|
24
- options.checks_directory = dir.to_s
25
- end
26
- opts.on_tail("-h", "--help", "Show this message") do
27
- puts opts
28
- exit
29
- end
30
- end
31
-
32
- # parse the options
33
- begin
34
- opts.parse!(args)
35
- rescue OptionParser::MissingArgument => e
36
- # if an --option is missing it's argument
37
- puts e.message.capitalize + "\n\n"
38
- puts opts
39
- exit 1
40
- end
41
-
42
- # default the port
43
- options.host ||= 'localhost'
44
- options.port ||= 11300
45
- options.checks_directory ||= File.join(File.dirname(__FILE__), '..', 'checks')
46
-
47
- options
48
- end
49
- end
50
- end
51
-