sensu 0.9.7.beta → 0.9.7.beta.1
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/CHANGELOG.md +10 -0
- data/lib/sensu/api.rb +3 -1
- data/lib/sensu/base.rb +1 -1
- data/lib/sensu/client.rb +25 -18
- data/lib/sensu/constants.rb +1 -1
- data/lib/sensu/server.rb +74 -25
- data/lib/sensu/settings.rb +16 -0
- data/lib/sensu/socket.rb +1 -1
- data/sensu.gemspec +5 -5
- metadata +26 -19
data/CHANGELOG.md
CHANGED
@@ -10,3 +10,13 @@ sending to a handler.
|
|
10
10
|
AMQP handlers can no longer use `"send_only_check_output": true`, but
|
11
11
|
instead have access to the built-in mutators `"mutator": "only_check_output"` and
|
12
12
|
`"mutator": "only_check_output_split"`.
|
13
|
+
|
14
|
+
### Other
|
15
|
+
|
16
|
+
Improved graceful process termination.
|
17
|
+
|
18
|
+
Improved client socket ping/pong.
|
19
|
+
|
20
|
+
Strict dependency version locking.
|
21
|
+
|
22
|
+
Adjusted logging level for metric check results and events.
|
data/lib/sensu/api.rb
CHANGED
data/lib/sensu/base.rb
CHANGED
data/lib/sensu/client.rb
CHANGED
@@ -67,7 +67,13 @@ module Sensu
|
|
67
67
|
:client => @settings[:client][:name],
|
68
68
|
:check => check
|
69
69
|
}
|
70
|
-
|
70
|
+
log_level = :info
|
71
|
+
if @settings.check_exists?(check[:name])
|
72
|
+
if @settings[:checks][check[:name]][:type] == 'metric'
|
73
|
+
log_level = :debug
|
74
|
+
end
|
75
|
+
end
|
76
|
+
@logger.send(log_level, 'publishing check result', {
|
71
77
|
:payload => payload
|
72
78
|
})
|
73
79
|
@amq.queue('results').publish(payload.to_json)
|
@@ -234,15 +240,10 @@ module Sensu
|
|
234
240
|
def unsubscribe(&block)
|
235
241
|
if @rabbitmq.connected?
|
236
242
|
@logger.warn('unsubscribing from client subscriptions')
|
237
|
-
@check_request_queue.unsubscribe
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
end
|
242
|
-
else
|
243
|
-
if block
|
244
|
-
block.call
|
245
|
-
end
|
243
|
+
@check_request_queue.unsubscribe
|
244
|
+
end
|
245
|
+
if block
|
246
|
+
block.call
|
246
247
|
end
|
247
248
|
end
|
248
249
|
|
@@ -250,14 +251,12 @@ module Sensu
|
|
250
251
|
@logger.info('completing checks in progress', {
|
251
252
|
:checks_in_progress => @checks_in_progress
|
252
253
|
})
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
if block
|
260
|
-
block.call
|
254
|
+
if block
|
255
|
+
retry_until_true do
|
256
|
+
if @checks_in_progress.empty?
|
257
|
+
block.call
|
258
|
+
true
|
259
|
+
end
|
261
260
|
end
|
262
261
|
end
|
263
262
|
end
|
@@ -283,5 +282,13 @@ module Sensu
|
|
283
282
|
def testing?
|
284
283
|
File.basename($0) == 'rake'
|
285
284
|
end
|
285
|
+
|
286
|
+
def retry_until_true(wait=0.5, &block)
|
287
|
+
EM::add_timer(wait) do
|
288
|
+
unless block.call
|
289
|
+
retry_until_true(wait, &block)
|
290
|
+
end
|
291
|
+
end
|
292
|
+
end
|
286
293
|
end
|
287
294
|
end
|
data/lib/sensu/constants.rb
CHANGED
data/lib/sensu/server.rb
CHANGED
@@ -28,7 +28,7 @@ module Sensu
|
|
28
28
|
base = Sensu::Base.new(options)
|
29
29
|
@settings = base.settings
|
30
30
|
@timers = Array.new
|
31
|
-
@
|
31
|
+
@handlers_in_progress_count = 0
|
32
32
|
end
|
33
33
|
|
34
34
|
def setup_redis
|
@@ -176,7 +176,7 @@ module Sensu
|
|
176
176
|
io.close_write
|
177
177
|
mutated = io.read
|
178
178
|
end
|
179
|
-
|
179
|
+
if $?.exitstatus != 0
|
180
180
|
@logger.warn('mutator had a non-zero exit status', {
|
181
181
|
:event => event,
|
182
182
|
:mutator => mutator
|
@@ -211,7 +211,7 @@ module Sensu
|
|
211
211
|
:event => event,
|
212
212
|
:handler => handler
|
213
213
|
})
|
214
|
-
@
|
214
|
+
@handlers_in_progress_count += 1
|
215
215
|
case handler[:type]
|
216
216
|
when 'pipe'
|
217
217
|
execute = Proc.new do
|
@@ -235,19 +235,43 @@ module Sensu
|
|
235
235
|
end
|
236
236
|
end
|
237
237
|
complete = Proc.new do
|
238
|
-
@
|
238
|
+
@handlers_in_progress_count -= 1
|
239
239
|
end
|
240
240
|
EM::defer(execute, complete)
|
241
|
+
when 'tcp', 'udp'
|
242
|
+
data = Proc.new do
|
243
|
+
mutate_event_data(handler, event)
|
244
|
+
end
|
245
|
+
write = Proc.new do |data|
|
246
|
+
begin
|
247
|
+
case handler[:type]
|
248
|
+
when 'tcp'
|
249
|
+
EM::connect(handler[:socket][:host], handler[:socket][:port], nil) do |socket|
|
250
|
+
socket.send_data(data)
|
251
|
+
socket.close_connection_after_writing
|
252
|
+
end
|
253
|
+
when 'udp'
|
254
|
+
EM::open_datagram_socket('127.0.0.1', 0, nil) do |socket|
|
255
|
+
socket.send_datagram(data, handler[:socket][:host], handler[:socket][:port])
|
256
|
+
socket.close_connection_after_writing
|
257
|
+
end
|
258
|
+
end
|
259
|
+
rescue => error
|
260
|
+
@logger.error('handler error', {
|
261
|
+
:event => event,
|
262
|
+
:handler => handler,
|
263
|
+
:error => error.to_s
|
264
|
+
})
|
265
|
+
end
|
266
|
+
@handlers_in_progress_count -= 1
|
267
|
+
end
|
268
|
+
EM::defer(data, write)
|
241
269
|
when 'amqp'
|
242
270
|
exchange_name = handler[:exchange][:name]
|
243
271
|
exchange_type = handler[:exchange].has_key?(:type) ? handler[:exchange][:type].to_sym : :direct
|
244
272
|
exchange_options = handler[:exchange].reject do |key, value|
|
245
273
|
[:name, :type].include?(key)
|
246
274
|
end
|
247
|
-
@logger.debug('publishing event to an amqp exchange', {
|
248
|
-
:event => event,
|
249
|
-
:exchange => handler[:exchange]
|
250
|
-
})
|
251
275
|
payloads = Proc.new do
|
252
276
|
Array(mutate_event_data(handler, event))
|
253
277
|
end
|
@@ -257,14 +281,14 @@ module Sensu
|
|
257
281
|
@amq.method(exchange_type).call(exchange_name, exchange_options).publish(payload)
|
258
282
|
end
|
259
283
|
end
|
260
|
-
@
|
284
|
+
@handlers_in_progress_count -= 1
|
261
285
|
end
|
262
286
|
EM::defer(payloads, publish)
|
263
287
|
when 'set'
|
264
288
|
@logger.error('handler sets cannot be nested', {
|
265
289
|
:handler => handler
|
266
290
|
})
|
267
|
-
@
|
291
|
+
@handlers_in_progress_count -= 1
|
268
292
|
end
|
269
293
|
end
|
270
294
|
end
|
@@ -504,8 +528,19 @@ module Sensu
|
|
504
528
|
if @redis.connected? && @is_master
|
505
529
|
@redis.del('lock:master').callback do
|
506
530
|
@logger.warn('resigned as master')
|
507
|
-
|
508
|
-
|
531
|
+
@is_master = false
|
532
|
+
end
|
533
|
+
if block
|
534
|
+
timestamp = Time.now.to_i
|
535
|
+
retry_until_true do
|
536
|
+
if !@is_master
|
537
|
+
block.call
|
538
|
+
true
|
539
|
+
elsif Time.now.to_i - timestamp >= 5
|
540
|
+
@logger.warn('failed to resign as master')
|
541
|
+
block.call
|
542
|
+
true
|
543
|
+
end
|
509
544
|
end
|
510
545
|
end
|
511
546
|
else
|
@@ -549,11 +584,19 @@ module Sensu
|
|
549
584
|
def unsubscribe(&block)
|
550
585
|
if @rabbitmq.connected?
|
551
586
|
@logger.warn('unsubscribing from keepalives')
|
552
|
-
@keepalive_queue.unsubscribe
|
553
|
-
|
554
|
-
|
555
|
-
|
587
|
+
@keepalive_queue.unsubscribe
|
588
|
+
@logger.warn('unsubscribing from results')
|
589
|
+
@result_queue.unsubscribe
|
590
|
+
if block
|
591
|
+
timestamp = Time.now.to_i
|
592
|
+
retry_until_true do
|
593
|
+
if !@keepalive_queue.subscribed? && !@result_queue.subscribed?
|
594
|
+
block.call
|
595
|
+
true
|
596
|
+
elsif Time.now.to_i - timestamp >= 5
|
597
|
+
@logger.warn('failed to unsubscribe from keepalives and results')
|
556
598
|
block.call
|
599
|
+
true
|
557
600
|
end
|
558
601
|
end
|
559
602
|
end
|
@@ -566,16 +609,14 @@ module Sensu
|
|
566
609
|
|
567
610
|
def complete_handlers_in_progress(&block)
|
568
611
|
@logger.info('completing handlers in progress', {
|
569
|
-
:
|
612
|
+
:handlers_in_progress_count => @handlers_in_progress_count
|
570
613
|
})
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
if block
|
578
|
-
block.call
|
614
|
+
if block
|
615
|
+
retry_until_true do
|
616
|
+
if @handlers_in_progress_count == 0
|
617
|
+
block.call
|
618
|
+
true
|
619
|
+
end
|
579
620
|
end
|
580
621
|
end
|
581
622
|
end
|
@@ -604,5 +645,13 @@ module Sensu
|
|
604
645
|
def testing?
|
605
646
|
File.basename($0) == 'rake'
|
606
647
|
end
|
648
|
+
|
649
|
+
def retry_until_true(wait=0.5, &block)
|
650
|
+
EM::add_timer(wait) do
|
651
|
+
unless block.call
|
652
|
+
retry_until_true(wait, &block)
|
653
|
+
end
|
654
|
+
end
|
655
|
+
end
|
607
656
|
end
|
608
657
|
end
|
data/lib/sensu/settings.rb
CHANGED
@@ -334,6 +334,22 @@ module Sensu
|
|
334
334
|
:handler => handler
|
335
335
|
})
|
336
336
|
end
|
337
|
+
when 'tcp', 'udp'
|
338
|
+
unless handler[:socket].is_a?(Hash)
|
339
|
+
invalid('handler is missing socket hash', {
|
340
|
+
:handler => handler
|
341
|
+
})
|
342
|
+
end
|
343
|
+
unless handler[:socket][:host].is_a?(String)
|
344
|
+
invalid('handler is missing socket host', {
|
345
|
+
:handler => handler
|
346
|
+
})
|
347
|
+
end
|
348
|
+
unless handler[:socket][:port].is_a?(Integer)
|
349
|
+
invalid('handler is missing socket port', {
|
350
|
+
:handler => handler
|
351
|
+
})
|
352
|
+
end
|
337
353
|
when 'amqp'
|
338
354
|
unless handler[:exchange].is_a?(Hash)
|
339
355
|
invalid('handler is missing exchange hash', {
|
data/lib/sensu/socket.rb
CHANGED
data/sensu.gemspec
CHANGED
@@ -5,20 +5,20 @@ Gem::Specification.new do |s|
|
|
5
5
|
s.version = Sensu::VERSION
|
6
6
|
s.platform = Gem::Platform::RUBY
|
7
7
|
s.authors = ['Sean Porter', 'Justin Kolberg']
|
8
|
-
s.email = ['
|
8
|
+
s.email = ['portertech@gmail.com', 'justin.kolberg@sonian.net']
|
9
9
|
s.homepage = 'https://github.com/sensu/sensu'
|
10
10
|
s.summary = 'A monitoring framework'
|
11
11
|
s.description = 'A monitoring framework that aims to be simple, malleable, and scalable. Uses the publish/subscribe model.'
|
12
12
|
s.license = 'MIT'
|
13
13
|
s.has_rdoc = false
|
14
14
|
|
15
|
-
s.add_dependency('eventmachine', '
|
15
|
+
s.add_dependency('eventmachine', '1.0.0.rc.4')
|
16
16
|
s.add_dependency('amqp', '0.7.4')
|
17
|
-
s.add_dependency('json')
|
17
|
+
s.add_dependency('json', '1.7.3')
|
18
18
|
s.add_dependency('cabin', '0.4.4')
|
19
|
-
s.add_dependency('ruby-redis')
|
19
|
+
s.add_dependency('ruby-redis', '0.0.2')
|
20
20
|
s.add_dependency('async_sinatra', '1.0.0')
|
21
|
-
s.add_dependency('thin')
|
21
|
+
s.add_dependency('thin', '1.4.1')
|
22
22
|
|
23
23
|
s.add_development_dependency('rake')
|
24
24
|
s.add_development_dependency('em-spec')
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 62196233
|
5
5
|
prerelease: true
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 9
|
9
9
|
- 7
|
10
10
|
- beta
|
11
|
-
|
11
|
+
- 1
|
12
|
+
version: 0.9.7.beta.1
|
12
13
|
platform: ruby
|
13
14
|
authors:
|
14
15
|
- Sean Porter
|
@@ -17,7 +18,7 @@ autorequire:
|
|
17
18
|
bindir: bin
|
18
19
|
cert_chain: []
|
19
20
|
|
20
|
-
date: 2012-
|
21
|
+
date: 2012-08-06 00:00:00 -07:00
|
21
22
|
default_executable:
|
22
23
|
dependencies:
|
23
24
|
- !ruby/object:Gem::Dependency
|
@@ -26,16 +27,16 @@ dependencies:
|
|
26
27
|
requirement: &id001 !ruby/object:Gem::Requirement
|
27
28
|
none: false
|
28
29
|
requirements:
|
29
|
-
- -
|
30
|
+
- - "="
|
30
31
|
- !ruby/object:Gem::Version
|
31
|
-
hash:
|
32
|
+
hash: 15424061
|
32
33
|
segments:
|
33
34
|
- 1
|
34
35
|
- 0
|
35
36
|
- 0
|
36
|
-
-
|
37
|
+
- rc
|
37
38
|
- 4
|
38
|
-
version: 1.0.0.
|
39
|
+
version: 1.0.0.rc.4
|
39
40
|
type: :runtime
|
40
41
|
version_requirements: *id001
|
41
42
|
- !ruby/object:Gem::Dependency
|
@@ -60,12 +61,14 @@ dependencies:
|
|
60
61
|
requirement: &id003 !ruby/object:Gem::Requirement
|
61
62
|
none: false
|
62
63
|
requirements:
|
63
|
-
- - "
|
64
|
+
- - "="
|
64
65
|
- !ruby/object:Gem::Version
|
65
|
-
hash:
|
66
|
+
hash: 13
|
66
67
|
segments:
|
67
|
-
-
|
68
|
-
|
68
|
+
- 1
|
69
|
+
- 7
|
70
|
+
- 3
|
71
|
+
version: 1.7.3
|
69
72
|
type: :runtime
|
70
73
|
version_requirements: *id003
|
71
74
|
- !ruby/object:Gem::Dependency
|
@@ -90,12 +93,14 @@ dependencies:
|
|
90
93
|
requirement: &id005 !ruby/object:Gem::Requirement
|
91
94
|
none: false
|
92
95
|
requirements:
|
93
|
-
- - "
|
96
|
+
- - "="
|
94
97
|
- !ruby/object:Gem::Version
|
95
|
-
hash:
|
98
|
+
hash: 27
|
96
99
|
segments:
|
97
100
|
- 0
|
98
|
-
|
101
|
+
- 0
|
102
|
+
- 2
|
103
|
+
version: 0.0.2
|
99
104
|
type: :runtime
|
100
105
|
version_requirements: *id005
|
101
106
|
- !ruby/object:Gem::Dependency
|
@@ -120,12 +125,14 @@ dependencies:
|
|
120
125
|
requirement: &id007 !ruby/object:Gem::Requirement
|
121
126
|
none: false
|
122
127
|
requirements:
|
123
|
-
- - "
|
128
|
+
- - "="
|
124
129
|
- !ruby/object:Gem::Version
|
125
|
-
hash:
|
130
|
+
hash: 5
|
126
131
|
segments:
|
127
|
-
-
|
128
|
-
|
132
|
+
- 1
|
133
|
+
- 4
|
134
|
+
- 1
|
135
|
+
version: 1.4.1
|
129
136
|
type: :runtime
|
130
137
|
version_requirements: *id007
|
131
138
|
- !ruby/object:Gem::Dependency
|
@@ -172,7 +179,7 @@ dependencies:
|
|
172
179
|
version_requirements: *id010
|
173
180
|
description: A monitoring framework that aims to be simple, malleable, and scalable. Uses the publish/subscribe model.
|
174
181
|
email:
|
175
|
-
-
|
182
|
+
- portertech@gmail.com
|
176
183
|
- justin.kolberg@sonian.net
|
177
184
|
executables:
|
178
185
|
- sensu-api
|