sensu 0.22.2 → 0.23.0.beta

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5df636d0e0ef1eec740d1e53841710b12eea719a
4
- data.tar.gz: 698226c0a0f3b8c3e85d965eb77c1cd07a05d974
3
+ metadata.gz: 7b0c1933136a7aace8e886cb8796276eff73abd9
4
+ data.tar.gz: b9f4f1616c8b9746c7593ccc9e46c5bddf91ee4b
5
5
  SHA512:
6
- metadata.gz: 707b460bc8364bb2c1b487ffab671ab36198e05f17e17ef1dc3387a3c9283bfab2fc7ff5c702396735c83b27d6c886c03e191621596d17d47a6bda3e8a8a606c
7
- data.tar.gz: 384bf776798a56ff68bf048c2f4880d14bd496f4795521e4f57cc890253042776ed9f3e906398dd0b9b15fae3f3c5fae62476805e7304331220229227901e8f4
6
+ metadata.gz: 15ceca05ff255ddf025e7dc0fc36f54b69fbb7baa69ea5b9644026eef78f9dca4de2fa05eca067c6f222e2efd068954ced1de53a854d946eea594c8ef7c20c68
7
+ data.tar.gz: c4b90a4c84dd9d0aa8e5900aa83e7a3df90cf7899362ea1457ce6a4e40302f7a37052f33a6bd3449df7665bc47e6e916cde8d0520af14e451f77f8ccaafb3a39
data/CHANGELOG.md CHANGED
@@ -1,3 +1,43 @@
1
+ ## 0.23.0 - 2016-03-29
2
+
3
+ ### Important
4
+
5
+ Dropped support for Rubies < 2.0.0, as they have long been EOL and have
6
+ proven to be a hindrance and security risk.
7
+
8
+ The Sensu Transport API changed. Transports are now a deferrable, they
9
+ must call `succeed()` once they have fully initialized. Sensu now waits
10
+ for its transport to fully initialize before taking other actions.
11
+
12
+ ### Features
13
+
14
+ Redis Sentinel support for HA Redis. Sensu services can now be configured
15
+ to query one or more instances of Redis Sentinel for a Redis master. This
16
+ feature eliminates the last need for HAProxy in highly available Sensu
17
+ configurations. To configure Sensu services to use Redis Sentinel, hosts
18
+ and ports of one or more Sentinel instances must be provided, e.g.
19
+ `"sentinels": [{"host": "10.0.1.23", "port": 26479}]`.
20
+
21
+ Added a CLI option/argument to cause the Sensu service to print (output to
22
+ STDOUT) its compiled configuration settings and exit. The CLI option is
23
+ `--print_config` or `-P`.
24
+
25
+ Added token substitution to filter eval attributes, providing access to
26
+ event data, e.g. `"occurrences": "eval: value == :::check.occurrences:::"`.
27
+
28
+ The Sensu 0.23 packages use Ruby 2.3.
29
+
30
+ ### Other
31
+
32
+ Performance improvements. Dropped MultiJson in favour of Sensu JSON, a
33
+ lighter weight JSON parser abstraction that supports platform specific
34
+ parsers for Sensu Core and Enterprise. The Oj JSON parser is once again
35
+ used for Sensu Core. Used https://github.com/JuanitoFatas/fast-ruby and
36
+ benchmarks as a guide to further changes.
37
+
38
+ Using EventMachine 1.2.0, which brings several changes and improvements:
39
+ https://github.com/eventmachine/eventmachine/blob/master/CHANGELOG.md#1201-march-15-2016
40
+
1
41
  ## 0.22.2 - 2016-03-16
2
42
 
3
43
  ### Fixes
data/MIT-LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2015 Sonian Inc.
1
+ Copyright (c) 2016 Sonian Inc.
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -22,17 +22,20 @@ module Sensu
22
22
  bootstrap(options)
23
23
  setup_process(options)
24
24
  EM::run do
25
- start
26
- setup_signal_traps
25
+ setup_connections do
26
+ start
27
+ setup_signal_traps
28
+ end
27
29
  end
28
30
  end
29
31
 
30
- def on_reactor_run
31
- EM::next_tick do
32
- setup_redis
33
- set :redis, @redis
34
- setup_transport
35
- set :transport, @transport
32
+ def setup_connections
33
+ setup_redis do |redis|
34
+ set :redis, redis
35
+ setup_transport do |transport|
36
+ set :transport, transport
37
+ yield if block_given?
38
+ end
36
39
  end
37
40
  end
38
41
 
@@ -49,8 +52,6 @@ module Sensu
49
52
  "Credentials" => "true",
50
53
  "Headers" => "Origin, X-Requested-With, Content-Type, Accept, Authorization"
51
54
  }
52
- on_reactor_run
53
- self
54
55
  end
55
56
 
56
57
  def start_server
@@ -83,15 +84,18 @@ module Sensu
83
84
  def stop
84
85
  @logger.warn("stopping")
85
86
  stop_server do
86
- @redis.close
87
- @transport.close
87
+ settings.redis.close
88
+ settings.transport.close
88
89
  super
89
90
  end
90
91
  end
91
92
 
92
93
  def test(options={})
93
94
  bootstrap(options)
94
- start
95
+ setup_connections do
96
+ start
97
+ yield
98
+ end
95
99
  end
96
100
  end
97
101
 
@@ -163,7 +167,7 @@ module Sensu
163
167
  end
164
168
 
165
169
  def issued!
166
- accepted!(MultiJson.dump(:issued => Time.now.to_i))
170
+ accepted!(Sensu::JSON.dump(:issued => Time.now.to_i))
167
171
  end
168
172
 
169
173
  def no_content!
@@ -173,7 +177,7 @@ module Sensu
173
177
 
174
178
  def read_data(rules={})
175
179
  begin
176
- data = MultiJson.load(env["rack.input"].read)
180
+ data = Sensu::JSON.load(env["rack.input"].read)
177
181
  valid = rules.all? do |key, rule|
178
182
  value = data[key]
179
183
  (value.is_a?(rule[:type]) || (rule[:nil_ok] && value.nil?)) &&
@@ -185,7 +189,7 @@ module Sensu
185
189
  else
186
190
  bad_request!
187
191
  end
188
- rescue MultiJson::ParseError
192
+ rescue Sensu::JSON::ParseError
189
193
  bad_request!
190
194
  end
191
195
  end
@@ -198,10 +202,10 @@ module Sensu
198
202
  limit = integer_parameter(params[:limit])
199
203
  offset = integer_parameter(params[:offset]) || 0
200
204
  unless limit.nil?
201
- headers["X-Pagination"] = MultiJson.dump(
205
+ headers["X-Pagination"] = Sensu::JSON.dump(
202
206
  :limit => limit,
203
207
  :offset => offset,
204
- :total => items.size
208
+ :total => items.length
205
209
  )
206
210
  paginated = items.slice(offset, limit)
207
211
  Array(paginated)
@@ -244,7 +248,7 @@ module Sensu
244
248
  :check => check
245
249
  }
246
250
  settings.logger.info("publishing check result", :payload => payload)
247
- settings.transport.publish(:direct, "results", MultiJson.dump(payload)) do |info|
251
+ settings.transport.publish(:direct, "results", Sensu::JSON.dump(payload)) do |info|
248
252
  if info[:error]
249
253
  settings.logger.error("failed to publish check result", {
250
254
  :payload => payload,
@@ -255,7 +259,7 @@ module Sensu
255
259
  end
256
260
 
257
261
  def resolve_event(event_json)
258
- event = MultiJson.load(event_json)
262
+ event = Sensu::JSON.load(event_json)
259
263
  check = event[:check].merge(
260
264
  :output => "Resolving on request of the API",
261
265
  :status => 0,
@@ -282,7 +286,7 @@ module Sensu
282
286
  :subscribers => check[:subscribers]
283
287
  })
284
288
  check[:subscribers].each do |subscription|
285
- options = transport_publish_options(subscription.to_s, MultiJson.dump(payload))
289
+ options = transport_publish_options(subscription.to_s, Sensu::JSON.dump(payload))
286
290
  settings.transport.publish(*options) do |info|
287
291
  if info[:error]
288
292
  settings.logger.error("failed to publish check request", {
@@ -320,7 +324,7 @@ module Sensu
320
324
  :connected => settings.redis.connected?
321
325
  }
322
326
  }
323
- body MultiJson.dump(response)
327
+ body Sensu::JSON.dump(response)
324
328
  end
325
329
  end
326
330
 
@@ -355,9 +359,9 @@ module Sensu
355
359
  data[:keepalives] = false
356
360
  data[:version] = VERSION
357
361
  data[:timestamp] = Time.now.to_i
358
- settings.redis.set("client:#{data[:name]}", MultiJson.dump(data)) do
362
+ settings.redis.set("client:#{data[:name]}", Sensu::JSON.dump(data)) do
359
363
  settings.redis.sadd("clients", data[:name]) do
360
- created!(MultiJson.dump(:name => data[:name]))
364
+ created!(Sensu::JSON.dump(:name => data[:name]))
361
365
  end
362
366
  end
363
367
  end
@@ -371,18 +375,18 @@ module Sensu
371
375
  clients.each_with_index do |client_name, index|
372
376
  settings.redis.get("client:#{client_name}") do |client_json|
373
377
  unless client_json.nil?
374
- response << MultiJson.load(client_json)
378
+ response << Sensu::JSON.load(client_json)
375
379
  else
376
380
  settings.logger.error("client data missing from registry", :client_name => client_name)
377
381
  settings.redis.srem("clients", client_name)
378
382
  end
379
- if index == clients.size - 1
380
- body MultiJson.dump(response)
383
+ if index == clients.length - 1
384
+ body Sensu::JSON.dump(response)
381
385
  end
382
386
  end
383
387
  end
384
388
  else
385
- body MultiJson.dump(response)
389
+ body Sensu::JSON.dump(response)
386
390
  end
387
391
  end
388
392
  end
@@ -410,7 +414,7 @@ module Sensu
410
414
  end
411
415
  settings.redis.get("result:#{result_key}") do |result_json|
412
416
  unless result_json.nil?
413
- result = MultiJson.load(result_json)
417
+ result = Sensu::JSON.load(result_json)
414
418
  last_execution = result[:executed]
415
419
  unless history.empty? || last_execution.nil?
416
420
  item = {
@@ -423,14 +427,14 @@ module Sensu
423
427
  response << item
424
428
  end
425
429
  end
426
- if index == checks.size - 1
427
- body MultiJson.dump(response)
430
+ if index == checks.length - 1
431
+ body Sensu::JSON.dump(response)
428
432
  end
429
433
  end
430
434
  end
431
435
  end
432
436
  else
433
- body MultiJson.dump(response)
437
+ body Sensu::JSON.dump(response)
434
438
  end
435
439
  end
436
440
  end
@@ -477,13 +481,13 @@ module Sensu
477
481
  end
478
482
 
479
483
  aget "/checks/?" do
480
- body MultiJson.dump(settings.all_checks)
484
+ body Sensu::JSON.dump(settings.all_checks)
481
485
  end
482
486
 
483
487
  aget %r{^/checks?/([\w\.-]+)/?$} do |check_name|
484
488
  if settings.checks[check_name]
485
489
  response = settings.checks[check_name].merge(:name => check_name)
486
- body MultiJson.dump(response)
490
+ body Sensu::JSON.dump(response)
487
491
  else
488
492
  not_found!
489
493
  end
@@ -515,15 +519,15 @@ module Sensu
515
519
  clients.each_with_index do |client_name, index|
516
520
  settings.redis.hgetall("events:#{client_name}") do |events|
517
521
  events.each do |check_name, event_json|
518
- response << MultiJson.load(event_json)
522
+ response << Sensu::JSON.load(event_json)
519
523
  end
520
- if index == clients.size - 1
521
- body MultiJson.dump(response)
524
+ if index == clients.length - 1
525
+ body Sensu::JSON.dump(response)
522
526
  end
523
527
  end
524
528
  end
525
529
  else
526
- body MultiJson.dump(response)
530
+ body Sensu::JSON.dump(response)
527
531
  end
528
532
  end
529
533
  end
@@ -532,9 +536,9 @@ module Sensu
532
536
  response = Array.new
533
537
  settings.redis.hgetall("events:#{client_name}") do |events|
534
538
  events.each do |check_name, event_json|
535
- response << MultiJson.load(event_json)
539
+ response << Sensu::JSON.load(event_json)
536
540
  end
537
- body MultiJson.dump(response)
541
+ body Sensu::JSON.dump(response)
538
542
  end
539
543
  end
540
544
 
@@ -592,13 +596,13 @@ module Sensu
592
596
  :issued => aggregates
593
597
  }
594
598
  response << item
595
- if index == checks.size - 1
596
- body MultiJson.dump(response)
599
+ if index == checks.length - 1
600
+ body Sensu::JSON.dump(response)
597
601
  end
598
602
  end
599
603
  end
600
604
  else
601
- body MultiJson.dump(response)
605
+ body Sensu::JSON.dump(response)
602
606
  end
603
607
  end
604
608
  end
@@ -617,7 +621,7 @@ module Sensu
617
621
  issued > timestamp
618
622
  end
619
623
  end
620
- body MultiJson.dump(pagination(aggregates))
624
+ body Sensu::JSON.dump(pagination(aggregates))
621
625
  else
622
626
  not_found!
623
627
  end
@@ -653,7 +657,7 @@ module Sensu
653
657
  end
654
658
  settings.redis.hgetall("aggregation:#{result_set}") do |results|
655
659
  parsed_results = results.inject(Array.new) do |parsed, (client_name, check_json)|
656
- check = MultiJson.load(check_json)
660
+ check = Sensu::JSON.load(check_json)
657
661
  parsed << check.merge(:client => client_name)
658
662
  end
659
663
  if params[:summarize]
@@ -669,7 +673,7 @@ module Sensu
669
673
  if params[:results]
670
674
  response[:results] = parsed_results
671
675
  end
672
- body MultiJson.dump(response)
676
+ body Sensu::JSON.dump(response)
673
677
  end
674
678
  else
675
679
  not_found!
@@ -679,9 +683,9 @@ module Sensu
679
683
 
680
684
  apost %r{^/stash(?:es)?/(.*)/?} do |path|
681
685
  read_data do |data|
682
- settings.redis.set("stash:#{path}", MultiJson.dump(data)) do
686
+ settings.redis.set("stash:#{path}", Sensu::JSON.dump(data)) do
683
687
  settings.redis.sadd("stashes", path) do
684
- created!(MultiJson.dump(:path => path))
688
+ created!(Sensu::JSON.dump(:path => path))
685
689
  end
686
690
  end
687
691
  end
@@ -721,21 +725,21 @@ module Sensu
721
725
  unless stash_json.nil?
722
726
  item = {
723
727
  :path => path,
724
- :content => MultiJson.load(stash_json),
728
+ :content => Sensu::JSON.load(stash_json),
725
729
  :expire => ttl
726
730
  }
727
731
  response << item
728
732
  else
729
733
  settings.redis.srem("stashes", path)
730
734
  end
731
- if index == stashes.size - 1
732
- body MultiJson.dump(pagination(response))
735
+ if index == stashes.length - 1
736
+ body Sensu::JSON.dump(pagination(response))
733
737
  end
734
738
  end
735
739
  end
736
740
  end
737
741
  else
738
- body MultiJson.dump(response)
742
+ body Sensu::JSON.dump(response)
739
743
  end
740
744
  end
741
745
  end
@@ -748,9 +752,9 @@ module Sensu
748
752
  }
749
753
  read_data(rules) do |data|
750
754
  stash_key = "stash:#{data[:path]}"
751
- settings.redis.set(stash_key, MultiJson.dump(data[:content])) do
755
+ settings.redis.set(stash_key, Sensu::JSON.dump(data[:content])) do
752
756
  settings.redis.sadd("stashes", data[:path]) do
753
- response = MultiJson.dump(:path => data[:path])
757
+ response = Sensu::JSON.dump(:path => data[:path])
754
758
  if data[:expire]
755
759
  settings.redis.expire(stash_key, data[:expire]) do
756
760
  created!(response)
@@ -787,21 +791,21 @@ module Sensu
787
791
  result_key = "result:#{client_name}:#{check_name}"
788
792
  settings.redis.get(result_key) do |result_json|
789
793
  unless result_json.nil?
790
- check = MultiJson.load(result_json)
794
+ check = Sensu::JSON.load(result_json)
791
795
  response << {:client => client_name, :check => check}
792
796
  end
793
- if client_index == clients.size - 1 && check_index == checks.size - 1
794
- body MultiJson.dump(response)
797
+ if client_index == clients.length - 1 && check_index == checks.length - 1
798
+ body Sensu::JSON.dump(response)
795
799
  end
796
800
  end
797
801
  end
798
- elsif client_index == clients.size - 1
799
- body MultiJson.dump(response)
802
+ elsif client_index == clients.length - 1
803
+ body Sensu::JSON.dump(response)
800
804
  end
801
805
  end
802
806
  end
803
807
  else
804
- body MultiJson.dump(response)
808
+ body Sensu::JSON.dump(response)
805
809
  end
806
810
  end
807
811
  end
@@ -814,11 +818,11 @@ module Sensu
814
818
  result_key = "result:#{client_name}:#{check_name}"
815
819
  settings.redis.get(result_key) do |result_json|
816
820
  unless result_json.nil?
817
- check = MultiJson.load(result_json)
821
+ check = Sensu::JSON.load(result_json)
818
822
  response << {:client => client_name, :check => check}
819
823
  end
820
- if check_index == checks.size - 1
821
- body MultiJson.dump(response)
824
+ if check_index == checks.length - 1
825
+ body Sensu::JSON.dump(response)
822
826
  end
823
827
  end
824
828
  end
@@ -832,9 +836,9 @@ module Sensu
832
836
  result_key = "result:#{client_name}:#{check_name}"
833
837
  settings.redis.get(result_key) do |result_json|
834
838
  unless result_json.nil?
835
- check = MultiJson.load(result_json)
839
+ check = Sensu::JSON.load(result_json)
836
840
  response = {:client => client_name, :check => check}
837
- body MultiJson.dump(response)
841
+ body Sensu::JSON.dump(response)
838
842
  else
839
843
  not_found!
840
844
  end
data/lib/sensu/cli.rb CHANGED
@@ -26,6 +26,9 @@ module Sensu
26
26
  opts.on("-d", "--config_dir DIR[,DIR]", "DIR or comma-delimited DIR list for Sensu JSON config files") do |dir|
27
27
  options[:config_dirs] = dir.split(",")
28
28
  end
29
+ opts.on("-P", "--print_config", "Print the compiled configuration and exit") do
30
+ options[:print_config] = true
31
+ end
29
32
  opts.on("-e", "--extension_dir DIR", "DIR for Sensu extensions") do |dir|
30
33
  options[:extension_dir] = dir
31
34
  end