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
@@ -0,0 +1,55 @@
1
+ !!! 5
2
+ %html
3
+ %head
4
+ :css
5
+ * { margin: 0; padding: 0; }
6
+ html { font-size: 62.5%; }
7
+ body { font-size: 16px; }
8
+ div#wrapper {
9
+ margin: 24px auto;
10
+ width: 1000px;
11
+ }
12
+ h1, h2, h3, h4, h5 {
13
+ font-family: Helvetica Neue, sans-serif;
14
+ margin-bottom: 12px;
15
+ }
16
+ table {
17
+ text-align: left;
18
+ width: 100%;
19
+ }
20
+ table th {
21
+ font-family: Helvetica Neue, sans-serif;
22
+ background-color: #eee;
23
+ }
24
+ table td, table th {
25
+ padding: 4px;
26
+ }
27
+ table td.critical {
28
+ background-color: #fb9a99;
29
+ }
30
+ table td.down {
31
+ background-color: #fb9a99;
32
+ }
33
+ table td.warning {
34
+ background-color: #f9bb34;
35
+ }
36
+ table td.ok {
37
+ background-color: #B2DF8A;
38
+ }
39
+ table td.up {
40
+ background-color: #B2DF8A;
41
+ }
42
+ %body
43
+ %div#wrapper
44
+ %p
45
+ %a(title='Dashboard' href='/') All Checks
46
+ |
47
+ %a(title='Dashboard' href='/failing') Failing Checks
48
+ - if @acknowledge_success
49
+ %h1
50
+ %a(href="/check?entity=#{@entity}&check=#{@check}") #{@check} on #{@entity}
51
+ has been acknowledged
52
+ - else
53
+ %h1
54
+ Failed to acknowledge
55
+ %a(href="/check?entity=#{@entity}&check=#{@check}") #{@check} on #{@entity}
@@ -0,0 +1,162 @@
1
+ !!! 5
2
+ %html
3
+ %head
4
+ :css
5
+ * { margin: 0; padding: 0; }
6
+ html { font-size: 62.5%; }
7
+ body { font-size: 16px; }
8
+ div#wrapper {
9
+ margin: 24px auto;
10
+ width: 1000px;
11
+ }
12
+ h1, h2, h3, h4, h5 {
13
+ font-family: Helvetica Neue, sans-serif;
14
+ margin-bottom: 12px;
15
+ }
16
+ table {
17
+ text-align: left;
18
+ width: 100%;
19
+ }
20
+ table th {
21
+ font-family: Helvetica Neue, sans-serif;
22
+ background-color: #eee;
23
+ }
24
+ table td, table th {
25
+ padding: 4px;
26
+ }
27
+ table td.critical {
28
+ background-color: #fb9a99;
29
+ }
30
+ table td.down {
31
+ background-color: #fb9a99;
32
+ }
33
+ table td.warning {
34
+ background-color: #f9bb34;
35
+ }
36
+ table td.ok {
37
+ background-color: #B2DF8A;
38
+ }
39
+ table td.up {
40
+ background-color: #B2DF8A;
41
+ }
42
+ %body
43
+ %div#wrapper
44
+ %p
45
+ %a(title='Dashboard' href='/') All Checks
46
+ |
47
+ %a(title='Dashboard' href='/failing') Failing Checks
48
+ %h1 #{@check} on #{@entity}
49
+ %form{:action => "/acknowledgements/#{@entity}/#{@check}", :method => "post"}
50
+ %h2
51
+ State: #{@check_state ? @check_state.upcase : ''}
52
+ - if (['warning', 'critical'].include?(@check_state) and !(@in_unscheduled_maintenance || @in_scheduled_maintenance))
53
+ %input{:type => 'hidden', :name => 'acknowledgement_id', :value => "#{@acknowledgement_id}"}
54
+ %input{:type => 'submit', :value => 'Acknowledge', :class => 'button'}
55
+ with
56
+ %label{:for => 'summary'}
57
+ summary:
58
+ %input{:type => 'text', :name => 'summary', :value => ''}
59
+ %label{:for => 'duration'}
60
+ duration:
61
+ %input{:type => 'text', :name => 'duration', :value => ''}
62
+ - if @in_unscheduled_maintenance
63
+ %h3 (Acknowledged)
64
+ - if @in_scheduled_maintenance
65
+ %h3 (Scheduled Maintenance)
66
+ - if @in_unscheduled_maintenance
67
+ %form{:action => "/end_unscheduled_maintenance/#{@entity}/#{@check}", :method => "post"}
68
+ %p
69
+ %input{:type => 'submit', :value => 'End Unscheduled Maintenance (Unacknowledge)', :class => 'button'}
70
+ %h3 Output: #{@check_summary}
71
+ %table
72
+ %tr
73
+ %td Last state change:
74
+ %td #{relative_time_ago(Time.at(@check_last_change.to_i))} ago
75
+ %td #{Time.at(@check_last_change.to_i)}
76
+ %tr
77
+ %td Last update:
78
+ %td #{relative_time_ago(Time.at(@check_last_update.to_i))} ago
79
+ %td #{Time.at(@check_last_update.to_i)}
80
+ - if @last_notifications[:problem]
81
+ - last_problem_relative = relative_time_ago(Time.at(@last_notifications[:problem])) + " ago"
82
+ - last_problem = Time.at(@last_notifications[:problem]).to_s
83
+ - else
84
+ - last_problem_relative = 'never'
85
+ - last_problem = ''
86
+ %tr
87
+ %td Last problem notification:
88
+ %td= last_problem_relative
89
+ %td= last_problem
90
+ - if @last_notifications[:recovery]
91
+ - last_recovery_relative = relative_time_ago(Time.at(@last_notifications[:recovery])) + " ago"
92
+ - last_recovery = Time.at(@last_notifications[:recovery]).to_s
93
+ - else
94
+ - last_recovery_relative = 'never'
95
+ - last_recovery = ''
96
+ %tr
97
+ %td Last recovery notification:
98
+ %td= last_recovery_relative
99
+ %td= last_recovery
100
+ - if @last_notifications[:acknowledgement]
101
+ - last_ack_relative = relative_time_ago(Time.at(@last_notifications[:acknowledgement])) + " ago"
102
+ - last_ack = Time.at(@last_notifications[:acknowledgement]).to_s
103
+ - else
104
+ - last_ack_relative = 'never'
105
+ - last_ack = ''
106
+ %tr
107
+ %td Last acknowledgement notification:
108
+ %td= last_ack_relative
109
+ %td= last_ack
110
+ %h3 Scheduled Maintenance Periods
111
+ - if @scheduled_maintenances && (@scheduled_maintenances.length > 0)
112
+ %table
113
+ %tr
114
+ %th Start
115
+ %th End
116
+ %th Duration
117
+ %th Summary
118
+ %th Actions
119
+ - @scheduled_maintenances.sort_by {|s| s[:start_time]}.each do |scheduled_maintenance|
120
+ - start_time = scheduled_maintenance[:start_time]
121
+ - end_time = scheduled_maintenance[:end_time]
122
+ - duration = scheduled_maintenance[:duration]
123
+ - summary = scheduled_maintenance[:summary]
124
+ %tr
125
+ %td= Time.at(start_time).to_s
126
+ %td= Time.at(end_time).to_s
127
+ %td= ChronicDuration.output(duration)
128
+ %td= summary
129
+ %td
130
+ - if end_time > Time.now.to_i
131
+ %form{ :action => "/scheduled_maintenances/#{@entity}/#{@check}", :method => "post"}
132
+ %input{:type => 'hidden', :name => '_method', :value => 'delete'}
133
+ %input{:type => 'hidden', :name => 'start_time', :value => start_time}
134
+ %input{:type => 'submit', :value => 'Delete', :class => 'button'}
135
+ - else
136
+ %p No scheduled maintenance
137
+ %h4 Add Scheduled Maintenace
138
+ %form{:action => "/scheduled_maintenances/#{@entity}/#{@check}", :method => "post"}
139
+ %fieldset
140
+ %table
141
+ %tr
142
+ %td
143
+ %label{:for => 'start_time'} Start time:
144
+ %td
145
+ %input{:type => 'text', :name => 'start_time', :class => 'text', :size => '20', :maxlength => '80'}
146
+ %p uses chronic, so eg "today 4pm", "two hours hence", "friday 2pm", "2012-01-28 13:00", etc. Times are taken to be in #{local_timezone}
147
+ %tr
148
+ %td
149
+ %label{:for => 'duration'} Duration:
150
+ %td
151
+ %input{:type => 'text', :name => 'duration', :class => 'text', :size => '20', :maxlength => '80'}
152
+ %p uses chronic_duration, so eg "1 hour", "2:30:00", "three days", etc
153
+ %tr
154
+ %td
155
+ %label{:for => 'summary'} Summary:
156
+ %td
157
+ %input{:type => 'text', :name => 'summary', :class => 'text', :size => '80', :maxlength => '160'}
158
+ %tr
159
+ %td
160
+ %td
161
+ %input{:type => 'submit', :value => 'Save', :class => 'button'}
162
+
@@ -0,0 +1,92 @@
1
+ !!! 5
2
+ %html
3
+ %head
4
+ :css
5
+ * { margin: 0; padding: 0; }
6
+ html { font-size: 62.5%; }
7
+ body { font-size: 16px; }
8
+ div#wrapper {
9
+ margin: 24px auto;
10
+ width: 1000px;
11
+ }
12
+ h1, h2, h3, h4, h5 {
13
+ font-family: Helvetica Neue, sans-serif;
14
+ margin-bottom: 12px;
15
+ }
16
+ table {
17
+ text-align: left;
18
+ width: 100%;
19
+ }
20
+ table th {
21
+ font-family: Helvetica Neue, sans-serif;
22
+ background-color: #eee;
23
+ }
24
+ table td, table th {
25
+ padding: 4px;
26
+ }
27
+ table td.critical {
28
+ background-color: #fb9a99;
29
+ }
30
+ table td.down {
31
+ background-color: #fb9a99;
32
+ }
33
+ table td.warning {
34
+ background-color: #f9bb34;
35
+ }
36
+ table td.ok {
37
+ background-color: #B2DF8A;
38
+ }
39
+ table td.up {
40
+ background-color: #B2DF8A;
41
+ }
42
+ %body
43
+ %div#wrapper
44
+ %p
45
+ %a(title='internal stats' href='/') All Checks
46
+ |
47
+ %a(title='internal stats' href='/failing') Failing Checks
48
+ |
49
+ %a(title='internal stats' href='/self_stats') Internal Statistics
50
+ %h1 Flapjack Status
51
+ %h4
52
+ Events queued:
53
+ = @events_queued
54
+ %h4
55
+ All checks:
56
+ %a(title='all checks' href='/')
57
+ = @count_all_checks
58
+ %h4
59
+ Failing checks:
60
+ %a(title='failing checks' href='/failing')
61
+ = @count_failing_checks
62
+ %h3
63
+ All Checks
64
+ %table
65
+ %tr
66
+ %th Entity
67
+ %th Check
68
+ %th State
69
+ %th Last State Change
70
+ %th Last Update
71
+ %th Last Notification
72
+ - @states.each do |entity, check, status, changed, updated, in_unscheduled_outage, in_scheduled_outage, notified_kind, notified|
73
+ %tr
74
+ %td= entity
75
+ %td
76
+ - link = "/check?entity=" + entity + "&check=" + check
77
+ %a(title='check detail' href=link) #{check}
78
+ %td{:class => status}
79
+ = status.upcase
80
+ = " (Acknowledged)" if in_unscheduled_outage
81
+ = " (Scheduled Maintenance)" if in_scheduled_outage
82
+ %td= relative_time_ago(Time.at(changed.to_i)) + ' ago'
83
+ %td= (Time.now.to_i - updated.to_i).to_s + ' seconds ago'
84
+ - if notified && (notified > 0)
85
+ - last_notified = relative_time_ago(Time.at(notified.to_i)) + " ago, #{notified_kind}"
86
+ - else
87
+ - last_notified = 'never'
88
+ %td= last_notified
89
+
90
+ -#%ul
91
+ -#- @keys.each do |key|
92
+ -#%li= key
@@ -0,0 +1,56 @@
1
+ !!! 5
2
+ %html
3
+ %head
4
+ :css
5
+ * { margin: 0; padding: 0; }
6
+ html { font-size: 62.5%; }
7
+ body { font-size: 20px; }
8
+ div#wrapper {
9
+ margin: 24px auto;
10
+ width: 800px;
11
+ }
12
+ h1, h2, h3, h4, h5 {
13
+ font-family: Helvetica Neue, sans-serif;
14
+ margin-bottom: 12px;
15
+ }
16
+ table {
17
+ text-align: left;
18
+ width: 100%;
19
+ }
20
+ table th {
21
+ font-family: Helvetica Neue, sans-serif;
22
+ background-color: #eee;
23
+ }
24
+ table td, table th {
25
+ padding: 4px;
26
+ }
27
+ table td.critical {
28
+ background-color: #fb9a99;
29
+ }
30
+ table td.down {
31
+ background-color: #fb9a99;
32
+ }
33
+ table td.warning {
34
+ background-color: #f9bb34;
35
+ }
36
+ table td.ok {
37
+ background-color: #B2DF8A;
38
+ }
39
+ table td.up {
40
+ background-color: #B2DF8A;
41
+ }
42
+ %body
43
+ %div#wrapper
44
+ %h1 Flapjack Self Status
45
+ %h4
46
+ Events queued:
47
+ = @events_queued
48
+ %h4
49
+ Number of failing services:
50
+ = @count
51
+ %p Events processed: #{@event_counter_all} (ok: #{@event_counter_ok}, failure: #{@event_counter_failure}, action: #{@event_counter_action})
52
+ %p Average rate: #{@event_rate_all} events per second
53
+ %p Total keys in redis: #{@keys.length}
54
+ %p Uptime: #{@uptime_string}
55
+ %p Boot time: #{@boot_time}
56
+ %p Current time: #{Time.now}
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'ostruct'
4
+ require 'optparse'
5
+ require 'flapjack/patches'
6
+
7
+ module Flapjack
8
+ module Worker
9
+ class CLI
10
+ def self.parse(args)
11
+ options = OpenStruct.new
12
+ opts = OptionParser.new do |opts|
13
+ # the available command line options
14
+ opts.on('-b', '--beanstalk HOST', 'location of the beanstalkd') do |host|
15
+ options.host = host
16
+ end
17
+ opts.on('-p', '--port PORT', 'beanstalkd port') do |port|
18
+ options.port = port.to_i
19
+ end
20
+ opts.on('-c', '--checks-directory DIR', 'sandboxed check directory') do |dir|
21
+ options.checks_directory = dir.to_s
22
+ end
23
+ opts.on_tail("-h", "--help", "Show this message") do
24
+ puts opts
25
+ exit
26
+ end
27
+ end
28
+
29
+ # parse the options
30
+ begin
31
+ opts.parse!(args)
32
+ rescue OptionParser::MissingArgument => e
33
+ # if an --option is missing it's argument
34
+ puts e.message.capitalize + "\n\n"
35
+ puts opts
36
+ exit 1
37
+ end
38
+
39
+ # default the port
40
+ options.host ||= 'localhost'
41
+ options.port ||= 11300
42
+ options.checks_directory ||= File.join(File.dirname(__FILE__), '..', 'checks')
43
+
44
+ options
45
+ end
46
+ end
47
+ end
48
+ end
49
+
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes