sensu 0.12.1 → 0.12.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +11 -0
- data/lib/sensu/api.rb +40 -25
- data/lib/sensu/client.rb +16 -2
- data/lib/sensu/constants.rb +1 -1
- data/lib/sensu/rabbitmq.rb +1 -1
- data/lib/sensu/server.rb +26 -3
- metadata +4 -4
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
## 0.12.2 - 2013-11-22
|
2
|
+
|
3
|
+
### Other
|
4
|
+
|
5
|
+
API routes now have an optional trailing slash.
|
6
|
+
|
7
|
+
RabbitMQ initial connection timeout increased from 10 to 20 seconds.
|
8
|
+
|
9
|
+
RabbitMQ connection closed errors are now rescued when attempting to
|
10
|
+
publish to an exchange, while Sensu is reconnecting.
|
11
|
+
|
1
12
|
## 0.12.1 - 2013-11-02
|
2
13
|
|
3
14
|
### Features
|
data/lib/sensu/api.rb
CHANGED
@@ -253,7 +253,14 @@ module Sensu
|
|
253
253
|
$logger.info('publishing check result', {
|
254
254
|
:payload => payload
|
255
255
|
})
|
256
|
-
|
256
|
+
begin
|
257
|
+
$amq.direct('results').publish(Oj.dump(payload))
|
258
|
+
rescue AMQ::Client::ConnectionClosedError => error
|
259
|
+
$logger.error('failed to publish check result', {
|
260
|
+
:payload => payload,
|
261
|
+
:error => error.to_s
|
262
|
+
})
|
263
|
+
end
|
257
264
|
end
|
258
265
|
end
|
259
266
|
|
@@ -262,7 +269,7 @@ module Sensu
|
|
262
269
|
content_type 'application/json'
|
263
270
|
end
|
264
271
|
|
265
|
-
aget '/info' do
|
272
|
+
aget '/info/?' do
|
266
273
|
rabbitmq_info do |info|
|
267
274
|
response = {
|
268
275
|
:sensu => {
|
@@ -277,7 +284,7 @@ module Sensu
|
|
277
284
|
end
|
278
285
|
end
|
279
286
|
|
280
|
-
aget '/health' do
|
287
|
+
aget '/health/?' do
|
281
288
|
if $redis.connected? && $rabbitmq.connected?
|
282
289
|
healthy = Array.new
|
283
290
|
min_consumers = integer_parameter(params[:consumers])
|
@@ -298,7 +305,7 @@ module Sensu
|
|
298
305
|
end
|
299
306
|
end
|
300
307
|
|
301
|
-
aget '/clients' do
|
308
|
+
aget '/clients/?' do
|
302
309
|
response = Array.new
|
303
310
|
$redis.smembers('clients') do |clients|
|
304
311
|
clients = pagination(clients)
|
@@ -317,7 +324,7 @@ module Sensu
|
|
317
324
|
end
|
318
325
|
end
|
319
326
|
|
320
|
-
aget %r{/clients?/([\w\.-]+)
|
327
|
+
aget %r{/clients?/([\w\.-]+)/?$} do |client_name|
|
321
328
|
$redis.get('client:' + client_name) do |client_json|
|
322
329
|
unless client_json.nil?
|
323
330
|
body client_json
|
@@ -327,7 +334,7 @@ module Sensu
|
|
327
334
|
end
|
328
335
|
end
|
329
336
|
|
330
|
-
aget %r{/clients/([\w\.-]+)/history
|
337
|
+
aget %r{/clients/([\w\.-]+)/history/?$} do |client_name|
|
331
338
|
response = Array.new
|
332
339
|
$redis.smembers('history:' + client_name) do |checks|
|
333
340
|
unless checks.empty?
|
@@ -360,7 +367,7 @@ module Sensu
|
|
360
367
|
end
|
361
368
|
end
|
362
369
|
|
363
|
-
adelete %r{/clients?/([\w\.-]+)
|
370
|
+
adelete %r{/clients?/([\w\.-]+)/?$} do |client_name|
|
364
371
|
$redis.get('client:' + client_name) do |client_json|
|
365
372
|
unless client_json.nil?
|
366
373
|
$redis.hgetall('events:' + client_name) do |events|
|
@@ -392,11 +399,11 @@ module Sensu
|
|
392
399
|
end
|
393
400
|
end
|
394
401
|
|
395
|
-
aget '/checks' do
|
402
|
+
aget '/checks/?' do
|
396
403
|
body Oj.dump($settings.checks)
|
397
404
|
end
|
398
405
|
|
399
|
-
aget %r{/checks?/([\w\.-]+)
|
406
|
+
aget %r{/checks?/([\w\.-]+)/?$} do |check_name|
|
400
407
|
if $settings.check_exists?(check_name)
|
401
408
|
response = $settings[:checks][check_name].merge(:name => check_name)
|
402
409
|
body Oj.dump(response)
|
@@ -405,7 +412,7 @@ module Sensu
|
|
405
412
|
end
|
406
413
|
end
|
407
414
|
|
408
|
-
apost '/request' do
|
415
|
+
apost '/request/?' do
|
409
416
|
rules = {
|
410
417
|
:check => {:type => String, :nil_ok => false},
|
411
418
|
:subscribers => {:type => Array, :nil_ok => true}
|
@@ -424,7 +431,15 @@ module Sensu
|
|
424
431
|
:subscribers => subscribers
|
425
432
|
})
|
426
433
|
subscribers.uniq.each do |exchange_name|
|
427
|
-
|
434
|
+
begin
|
435
|
+
$amq.fanout(exchange_name).publish(Oj.dump(payload))
|
436
|
+
rescue AMQ::Client::ConnectionClosedError => error
|
437
|
+
$logger.error('failed to publish check request', {
|
438
|
+
:exchange_name => exchange_name,
|
439
|
+
:payload => payload,
|
440
|
+
:error => error.to_s
|
441
|
+
})
|
442
|
+
end
|
428
443
|
end
|
429
444
|
issued!
|
430
445
|
else
|
@@ -433,7 +448,7 @@ module Sensu
|
|
433
448
|
end
|
434
449
|
end
|
435
450
|
|
436
|
-
aget '/events' do
|
451
|
+
aget '/events/?' do
|
437
452
|
response = Array.new
|
438
453
|
$redis.smembers('clients') do |clients|
|
439
454
|
unless clients.empty?
|
@@ -453,7 +468,7 @@ module Sensu
|
|
453
468
|
end
|
454
469
|
end
|
455
470
|
|
456
|
-
aget %r{/events/([\w\.-]+)
|
471
|
+
aget %r{/events/([\w\.-]+)/?$} do |client_name|
|
457
472
|
response = Array.new
|
458
473
|
$redis.hgetall('events:' + client_name) do |events|
|
459
474
|
events.each do |check_name, event_json|
|
@@ -463,7 +478,7 @@ module Sensu
|
|
463
478
|
end
|
464
479
|
end
|
465
480
|
|
466
|
-
aget %r{/events?/([\w\.-]+)/([\w\.-]+)
|
481
|
+
aget %r{/events?/([\w\.-]+)/([\w\.-]+)/?$} do |client_name, check_name|
|
467
482
|
$redis.hgetall('events:' + client_name) do |events|
|
468
483
|
event_json = events[check_name]
|
469
484
|
unless event_json.nil?
|
@@ -474,7 +489,7 @@ module Sensu
|
|
474
489
|
end
|
475
490
|
end
|
476
491
|
|
477
|
-
adelete %r{/events?/([\w\.-]+)/([\w\.-]+)
|
492
|
+
adelete %r{/events?/([\w\.-]+)/([\w\.-]+)/?$} do |client_name, check_name|
|
478
493
|
$redis.hgetall('events:' + client_name) do |events|
|
479
494
|
if events.include?(check_name)
|
480
495
|
resolve_event(event_hash(events[check_name], client_name, check_name))
|
@@ -485,7 +500,7 @@ module Sensu
|
|
485
500
|
end
|
486
501
|
end
|
487
502
|
|
488
|
-
apost '/resolve' do
|
503
|
+
apost '/resolve/?' do
|
489
504
|
rules = {
|
490
505
|
:client => {:type => String, :nil_ok => false},
|
491
506
|
:check => {:type => String, :nil_ok => false}
|
@@ -502,7 +517,7 @@ module Sensu
|
|
502
517
|
end
|
503
518
|
end
|
504
519
|
|
505
|
-
aget '/aggregates' do
|
520
|
+
aget '/aggregates/?' do
|
506
521
|
response = Array.new
|
507
522
|
$redis.smembers('aggregates') do |checks|
|
508
523
|
unless checks.empty?
|
@@ -528,7 +543,7 @@ module Sensu
|
|
528
543
|
end
|
529
544
|
end
|
530
545
|
|
531
|
-
aget %r{/aggregates/([\w\.-]+)
|
546
|
+
aget %r{/aggregates/([\w\.-]+)/?$} do |check_name|
|
532
547
|
$redis.smembers('aggregates:' + check_name) do |aggregates|
|
533
548
|
unless aggregates.empty?
|
534
549
|
aggregates.reverse!
|
@@ -549,7 +564,7 @@ module Sensu
|
|
549
564
|
end
|
550
565
|
end
|
551
566
|
|
552
|
-
adelete %r{/aggregates/([\w\.-]+)
|
567
|
+
adelete %r{/aggregates/([\w\.-]+)/?$} do |check_name|
|
553
568
|
$redis.smembers('aggregates:' + check_name) do |aggregates|
|
554
569
|
unless aggregates.empty?
|
555
570
|
aggregates.each do |check_issued|
|
@@ -568,7 +583,7 @@ module Sensu
|
|
568
583
|
end
|
569
584
|
end
|
570
585
|
|
571
|
-
aget %r{/aggregates?/([\w\.-]+)/([\w\.-]+)
|
586
|
+
aget %r{/aggregates?/([\w\.-]+)/([\w\.-]+)/?$} do |check_name, check_issued|
|
572
587
|
result_set = check_name + ':' + check_issued
|
573
588
|
$redis.hgetall('aggregate:' + result_set) do |aggregate|
|
574
589
|
unless aggregate.empty?
|
@@ -602,7 +617,7 @@ module Sensu
|
|
602
617
|
end
|
603
618
|
end
|
604
619
|
|
605
|
-
apost %r{/stash(?:es)?/(.*)} do |path|
|
620
|
+
apost %r{/stash(?:es)?/(.*)/?} do |path|
|
606
621
|
read_data do |data|
|
607
622
|
$redis.set('stash:' + path, Oj.dump(data)) do
|
608
623
|
$redis.sadd('stashes', path) do
|
@@ -612,7 +627,7 @@ module Sensu
|
|
612
627
|
end
|
613
628
|
end
|
614
629
|
|
615
|
-
aget %r{/stash(?:es)?/(.*)} do |path|
|
630
|
+
aget %r{/stash(?:es)?/(.*)/?} do |path|
|
616
631
|
$redis.get('stash:' + path) do |stash_json|
|
617
632
|
unless stash_json.nil?
|
618
633
|
body stash_json
|
@@ -622,7 +637,7 @@ module Sensu
|
|
622
637
|
end
|
623
638
|
end
|
624
639
|
|
625
|
-
adelete %r{/stash(?:es)?/(.*)} do |path|
|
640
|
+
adelete %r{/stash(?:es)?/(.*)/?} do |path|
|
626
641
|
$redis.exists('stash:' + path) do |stash_exists|
|
627
642
|
if stash_exists
|
628
643
|
$redis.srem('stashes', path) do
|
@@ -636,7 +651,7 @@ module Sensu
|
|
636
651
|
end
|
637
652
|
end
|
638
653
|
|
639
|
-
aget '/stashes' do
|
654
|
+
aget '/stashes/?' do
|
640
655
|
response = Array.new
|
641
656
|
$redis.smembers('stashes') do |stashes|
|
642
657
|
unless stashes.empty?
|
@@ -665,7 +680,7 @@ module Sensu
|
|
665
680
|
end
|
666
681
|
end
|
667
682
|
|
668
|
-
apost '/stashes' do
|
683
|
+
apost '/stashes/?' do
|
669
684
|
rules = {
|
670
685
|
:path => {:type => String, :nil_ok => false},
|
671
686
|
:content => {:type => Hash, :nil_ok => false},
|
data/lib/sensu/client.rb
CHANGED
@@ -53,7 +53,14 @@ module Sensu
|
|
53
53
|
@logger.debug('publishing keepalive', {
|
54
54
|
:payload => payload
|
55
55
|
})
|
56
|
-
|
56
|
+
begin
|
57
|
+
@amq.direct('keepalives').publish(Oj.dump(payload))
|
58
|
+
rescue AMQ::Client::ConnectionClosedError => error
|
59
|
+
@logger.error('failed to publish keepalive', {
|
60
|
+
:payload => payload,
|
61
|
+
:error => error.to_s
|
62
|
+
})
|
63
|
+
end
|
57
64
|
end
|
58
65
|
|
59
66
|
def setup_keepalives
|
@@ -74,7 +81,14 @@ module Sensu
|
|
74
81
|
@logger.info('publishing check result', {
|
75
82
|
:payload => payload
|
76
83
|
})
|
77
|
-
|
84
|
+
begin
|
85
|
+
@amq.direct('results').publish(Oj.dump(payload))
|
86
|
+
rescue AMQ::Client::ConnectionClosedError => error
|
87
|
+
@logger.error('failed to publish check result', {
|
88
|
+
:payload => payload,
|
89
|
+
:error => error.to_s
|
90
|
+
})
|
91
|
+
end
|
78
92
|
end
|
79
93
|
|
80
94
|
def substitute_command_tokens(check)
|
data/lib/sensu/constants.rb
CHANGED
data/lib/sensu/rabbitmq.rb
CHANGED
data/lib/sensu/server.rb
CHANGED
@@ -339,7 +339,15 @@ module Sensu
|
|
339
339
|
[:name, :type].include?(key)
|
340
340
|
end
|
341
341
|
unless event_data.empty?
|
342
|
-
|
342
|
+
begin
|
343
|
+
@amq.method(exchange_type).call(exchange_name, exchange_options).publish(event_data)
|
344
|
+
rescue AMQ::Client::ConnectionClosedError => error
|
345
|
+
@logger.error('failed to publish event data to an exchange', {
|
346
|
+
:exchange => handler[:exchange],
|
347
|
+
:payload => event_data,
|
348
|
+
:error => error.to_s
|
349
|
+
})
|
350
|
+
end
|
343
351
|
end
|
344
352
|
@handlers_in_progress_count -= 1
|
345
353
|
when 'extension'
|
@@ -514,7 +522,15 @@ module Sensu
|
|
514
522
|
:subscribers => check[:subscribers]
|
515
523
|
})
|
516
524
|
check[:subscribers].each do |exchange_name|
|
517
|
-
|
525
|
+
begin
|
526
|
+
@amq.fanout(exchange_name).publish(Oj.dump(payload))
|
527
|
+
rescue AMQ::Client::ConnectionClosedError => error
|
528
|
+
@logger.error('failed to publish check request', {
|
529
|
+
:exchange_name => exchange_name,
|
530
|
+
:payload => payload,
|
531
|
+
:error => error.to_s
|
532
|
+
})
|
533
|
+
end
|
518
534
|
end
|
519
535
|
end
|
520
536
|
|
@@ -558,7 +574,14 @@ module Sensu
|
|
558
574
|
@logger.debug('publishing check result', {
|
559
575
|
:payload => payload
|
560
576
|
})
|
561
|
-
|
577
|
+
begin
|
578
|
+
@amq.direct('results').publish(Oj.dump(payload))
|
579
|
+
rescue AMQ::Client::ConnectionClosedError => error
|
580
|
+
@logger.error('failed to publish check result', {
|
581
|
+
:payload => payload,
|
582
|
+
:error => error.to_s
|
583
|
+
})
|
584
|
+
end
|
562
585
|
end
|
563
586
|
|
564
587
|
def determine_stale_clients
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 43
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 12
|
9
|
-
-
|
10
|
-
version: 0.12.
|
9
|
+
- 2
|
10
|
+
version: 0.12.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Sean Porter
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2013-11-
|
19
|
+
date: 2013-11-22 00:00:00 -08:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|