sensu 0.9.12.beta.2 → 0.9.12.beta.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +6 -0
- data/lib/sensu/client.rb +11 -5
- data/lib/sensu/constants.rb +1 -1
- data/lib/sensu/extensions.rb +23 -0
- data/lib/sensu/server.rb +29 -37
- data/lib/sensu/settings.rb +1 -1
- metadata +4 -4
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
### Features
|
4
4
|
|
5
|
+
Extension stop hook for clean up before the event loop is stopped.
|
6
|
+
|
5
7
|
Check extensions.
|
6
8
|
|
7
9
|
### Non-backwards compatible changes
|
@@ -10,6 +12,10 @@ No longer defaults to or enforces a specific config file or directory.
|
|
10
12
|
|
11
13
|
### Other
|
12
14
|
|
15
|
+
Improved RabbitMQ queue unsubscribe & connection reconnect.
|
16
|
+
|
17
|
+
Fixed keepalive check history & flap detection.
|
18
|
+
|
13
19
|
Running on Ruby 2.0.0p0.
|
14
20
|
|
15
21
|
Faster JSON parser.
|
data/lib/sensu/client.rb
CHANGED
@@ -242,10 +242,15 @@ module Sensu
|
|
242
242
|
end
|
243
243
|
end
|
244
244
|
|
245
|
-
def unsubscribe
|
245
|
+
def unsubscribe
|
246
246
|
@logger.warn('unsubscribing from client subscriptions')
|
247
|
-
@
|
248
|
-
|
247
|
+
if @rabbitmq.connected?
|
248
|
+
@check_request_queue.unsubscribe
|
249
|
+
else
|
250
|
+
@check_request_queue.before_recovery do
|
251
|
+
@check_request_queue.unsubscribe
|
252
|
+
end
|
253
|
+
end
|
249
254
|
end
|
250
255
|
|
251
256
|
def complete_checks_in_progress(&block)
|
@@ -273,8 +278,9 @@ module Sensu
|
|
273
278
|
@timers.each do |timer|
|
274
279
|
timer.cancel
|
275
280
|
end
|
276
|
-
unsubscribe
|
277
|
-
|
281
|
+
unsubscribe
|
282
|
+
complete_checks_in_progress do
|
283
|
+
@extensions.stop_all do
|
278
284
|
@rabbitmq.close
|
279
285
|
@logger.warn('stopping reactor')
|
280
286
|
EM::stop_event_loop
|
data/lib/sensu/constants.rb
CHANGED
data/lib/sensu/extensions.rb
CHANGED
@@ -53,6 +53,25 @@ module Sensu
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
+
def stop_all(&block)
|
57
|
+
all = @extensions.map do |category, extensions|
|
58
|
+
extensions.map do |name, extension|
|
59
|
+
extension
|
60
|
+
end
|
61
|
+
end
|
62
|
+
all.flatten!
|
63
|
+
stopper = Proc.new do |extension|
|
64
|
+
if extension.nil?
|
65
|
+
block.call
|
66
|
+
else
|
67
|
+
extension.stop do
|
68
|
+
stopper.call(all.pop)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
stopper.call(all.pop)
|
73
|
+
end
|
74
|
+
|
56
75
|
private
|
57
76
|
|
58
77
|
def loaded(type, name, description)
|
@@ -93,6 +112,10 @@ module Sensu
|
|
93
112
|
block.call('noop', 0)
|
94
113
|
end
|
95
114
|
|
115
|
+
def stop(&block)
|
116
|
+
block.call
|
117
|
+
end
|
118
|
+
|
96
119
|
def self.descendants
|
97
120
|
ObjectSpace.each_object(Class).select do |klass|
|
98
121
|
klass < self
|
data/lib/sensu/server.rb
CHANGED
@@ -41,8 +41,8 @@ module Sensu
|
|
41
41
|
stop
|
42
42
|
end
|
43
43
|
@redis.before_reconnect do
|
44
|
-
@logger.warn('reconnecting to redis')
|
45
44
|
unless testing?
|
45
|
+
@logger.warn('reconnecting to redis')
|
46
46
|
pause
|
47
47
|
end
|
48
48
|
end
|
@@ -64,12 +64,15 @@ module Sensu
|
|
64
64
|
stop
|
65
65
|
end
|
66
66
|
@rabbitmq.before_reconnect do
|
67
|
-
|
68
|
-
|
67
|
+
unless testing?
|
68
|
+
@logger.warn('reconnecting to rabbitmq')
|
69
|
+
pause
|
70
|
+
end
|
69
71
|
end
|
70
72
|
@rabbitmq.after_reconnect do
|
71
73
|
@logger.info('reconnected to rabbitmq')
|
72
74
|
@amq.prefetch(1)
|
75
|
+
resume
|
73
76
|
end
|
74
77
|
@amq = @rabbitmq.channel
|
75
78
|
@amq.prefetch(1)
|
@@ -77,9 +80,6 @@ module Sensu
|
|
77
80
|
|
78
81
|
def setup_keepalives
|
79
82
|
@logger.debug('subscribing to keepalives')
|
80
|
-
@amq.queue('keepalives').consumers.each do |consumer_tag, consumer|
|
81
|
-
consumer.cancel
|
82
|
-
end
|
83
83
|
@keepalive_queue = @amq.queue!('keepalives')
|
84
84
|
@keepalive_queue.bind(@amq.direct('keepalives'))
|
85
85
|
@keepalive_queue.subscribe(:ack => true) do |header, payload|
|
@@ -502,9 +502,6 @@ module Sensu
|
|
502
502
|
|
503
503
|
def setup_results
|
504
504
|
@logger.debug('subscribing to results')
|
505
|
-
@amq.queue('results').consumers.each do |consumer_tag, consumer|
|
506
|
-
consumer.cancel
|
507
|
-
end
|
508
505
|
@result_queue = @amq.queue!('results')
|
509
506
|
@result_queue.bind(@amq.direct('results'))
|
510
507
|
@result_queue.subscribe(:ack => true) do |header, payload|
|
@@ -684,7 +681,7 @@ module Sensu
|
|
684
681
|
@redis.set('lock:master', Time.now.to_i) do
|
685
682
|
@logger.debug('updated master lock timestamp')
|
686
683
|
end
|
687
|
-
|
684
|
+
else
|
688
685
|
request_master_election
|
689
686
|
end
|
690
687
|
end
|
@@ -697,7 +694,7 @@ module Sensu
|
|
697
694
|
@master_timers.each do |timer|
|
698
695
|
timer.cancel
|
699
696
|
end
|
700
|
-
@master_timers
|
697
|
+
@master_timers.clear
|
701
698
|
if @redis.connected?
|
702
699
|
@redis.del('lock:master') do
|
703
700
|
@logger.info('removed master lock')
|
@@ -722,25 +719,19 @@ module Sensu
|
|
722
719
|
end
|
723
720
|
end
|
724
721
|
|
725
|
-
def unsubscribe
|
722
|
+
def unsubscribe
|
726
723
|
@logger.warn('unsubscribing from keepalive and result queues')
|
727
|
-
@keepalive_queue.unsubscribe
|
728
|
-
@result_queue.unsubscribe
|
729
724
|
if @rabbitmq.connected?
|
725
|
+
@keepalive_queue.unsubscribe
|
726
|
+
@result_queue.unsubscribe
|
730
727
|
@amq.recover
|
731
|
-
timestamp = Time.now.to_i
|
732
|
-
retry_until_true do
|
733
|
-
if !@keepalive_queue.subscribed? && !@result_queue.subscribed?
|
734
|
-
block.call
|
735
|
-
true
|
736
|
-
elsif Time.now.to_i - timestamp >= 5
|
737
|
-
@logger.warn('failed to unsubscribe from keepalive and result queues')
|
738
|
-
block.call
|
739
|
-
true
|
740
|
-
end
|
741
|
-
end
|
742
728
|
else
|
743
|
-
|
729
|
+
@keepalive_queue.before_recovery do
|
730
|
+
@keepalive_queue.unsubscribe
|
731
|
+
end
|
732
|
+
@result_queue.before_recovery do
|
733
|
+
@result_queue.unsubscribe
|
734
|
+
end
|
744
735
|
end
|
745
736
|
end
|
746
737
|
|
@@ -775,13 +766,12 @@ module Sensu
|
|
775
766
|
@timers.each do |timer|
|
776
767
|
timer.cancel
|
777
768
|
end
|
778
|
-
@timers
|
779
|
-
unsubscribe
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
end
|
769
|
+
@timers.clear
|
770
|
+
unsubscribe
|
771
|
+
resign_as_master do
|
772
|
+
@state = :paused
|
773
|
+
if block
|
774
|
+
block.call
|
785
775
|
end
|
786
776
|
end
|
787
777
|
end
|
@@ -803,10 +793,12 @@ module Sensu
|
|
803
793
|
@state = :stopping
|
804
794
|
pause do
|
805
795
|
complete_handlers_in_progress do
|
806
|
-
@
|
807
|
-
|
808
|
-
|
809
|
-
|
796
|
+
@extensions.stop_all do
|
797
|
+
@redis.close
|
798
|
+
@rabbitmq.close
|
799
|
+
@logger.warn('stopping reactor')
|
800
|
+
EM::stop_event_loop
|
801
|
+
end
|
810
802
|
end
|
811
803
|
end
|
812
804
|
end
|
data/lib/sensu/settings.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 2789372299
|
5
5
|
prerelease: true
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 9
|
9
9
|
- 12
|
10
10
|
- beta
|
11
|
-
-
|
12
|
-
version: 0.9.12.beta.
|
11
|
+
- 3
|
12
|
+
version: 0.9.12.beta.3
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- Sean Porter
|
@@ -18,7 +18,7 @@ autorequire:
|
|
18
18
|
bindir: bin
|
19
19
|
cert_chain: []
|
20
20
|
|
21
|
-
date: 2013-03-
|
21
|
+
date: 2013-03-06 00:00:00 -08:00
|
22
22
|
default_executable:
|
23
23
|
dependencies:
|
24
24
|
- !ruby/object:Gem::Dependency
|