sensu 0.29.0 → 1.0.0.alpha.1

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: 31731ea9a2311f9aecc12057e03442fb2dffca7e
4
- data.tar.gz: ee7b95c65a89a73693717c5220bf7a515ee54634
3
+ metadata.gz: b1bd5a84798800c4931deb2ea2d3c1683f9759a7
4
+ data.tar.gz: c6c83bcba2fbac47d21e3979b3f10299b42b1ec4
5
5
  SHA512:
6
- metadata.gz: b1a0e54b2e28998c7653b78f54278ec6f28c2a716fedfc8ab24b59108d33ff9998d60b77776c05e48e556b1decf43c15a2c95ee06842528ae3671cbd7957349a
7
- data.tar.gz: d7ed4d7d2cb4794ab2933237d383eb37331dda2adaed120117c25ce36cacb7d4a4cd6e8249439d5f08c1ed52e2e63b5e48e2594603078bcf9f120ca6a52d936b
6
+ metadata.gz: 1957e35b7dd9c97401d94862937a44d2fa6c92e78355088c45612a095185f692575fe8593b3edb9245e6ce904b7f6d78cb5bde4abd5a4c1b256b9b8879368fde
7
+ data.tar.gz: 672728ffed2a8e2760d7708b61e400b4fbf217996551d32ac87a647f33a764809169d7965e99204a8bd3429af659966cf897d3e92ddb3e9813d92a25eb7de2c5
data/CHANGELOG.md CHANGED
@@ -1,3 +1,27 @@
1
+ ## 1.0.0 - TBD
2
+
3
+ ### Other
4
+
5
+ Improved Sensu client keepalive configuration validation, now including
6
+ coverage for low/high flap thresholds etc.
7
+
8
+ Improved Sensu client socket check result validation, now including
9
+ coverage for low/high flap thresholds etc.
10
+
11
+ The `sensu-install` tool now notifies users when it is unable to
12
+ successfully install an extension, when the environment variable
13
+ EMBEDDED_RUBY is set to `false`.
14
+
15
+ Added the Sensu `RELEASE_INFO` constant, containing information about the
16
+ Sensu release, used by the API `/info` endpoint and Server registration.
17
+
18
+ ### Fixes
19
+
20
+ Sensu handler severities filtering now accounts for flapping events.
21
+
22
+ Fixed Sensu Redis connection on error reconnect, no longer reusing the
23
+ existing EventMachine connection handler.
24
+
1
25
  ## 0.29.0 - 2017-03-29
2
26
 
3
27
  ### Features
data/exe/sensu-install CHANGED
@@ -148,6 +148,11 @@ module Sensu
148
148
  end
149
149
 
150
150
  def install_extensions(extensions, options={})
151
+ if ENV["EMBEDDED_RUBY"] == "false"
152
+ log "EMBEDDED_RUBY must be set to true in order to install extensions"
153
+ log "failed to install extensions: #{extensions}"
154
+ exit 2
155
+ end
151
156
  log "installing Sensu extensions ..."
152
157
  log "provided Sensu extensions: #{extensions}" if options[:verbose]
153
158
  extension_gems = extensions.map do |extension|
@@ -14,13 +14,13 @@ module Sensu
14
14
  def get_info
15
15
  transport_info do |transport|
16
16
  servers_info do |servers|
17
+ sensu = RELEASE_INFO.merge(
18
+ :settings => {
19
+ :hexdigest => @settings.hexdigest
20
+ }
21
+ )
17
22
  @response_content = {
18
- :sensu => {
19
- :version => VERSION,
20
- :settings => {
21
- :hexdigest => @settings.hexdigest
22
- }
23
- },
23
+ :sensu => sensu,
24
24
  :transport => transport,
25
25
  :redis => {
26
26
  :connected => @redis.connected?
@@ -1,18 +1,18 @@
1
1
  require "sensu/json"
2
+ require "sensu/client/validators/check"
2
3
 
3
4
  module Sensu
4
5
  module Client
5
6
  module CheckUtils
6
7
  class DataError < StandardError; end
8
+
7
9
  # Validate check result attributes.
8
10
  #
9
11
  # @param [Hash] check result to validate.
10
12
  def validate_check_result(check)
11
- unless check[:name] =~ /\A[\w\.-]+\z/
12
- raise DataError, "check name must be a string and cannot contain spaces or special characters"
13
- end
14
- unless check[:source].nil? || check[:source] =~ /\A[\w\.-]+\z/
15
- raise DataError, "check source must be a string and cannot contain spaces or special characters"
13
+ validator = Validators::Check.new
14
+ unless validator.valid?(check)
15
+ raise DataError, validator.failures.first[:message]
16
16
  end
17
17
  unless check[:output].is_a?(String)
18
18
  raise DataError, "check output must be a string"
@@ -23,9 +23,6 @@ module Sensu
23
23
  unless check[:executed].is_a?(Integer)
24
24
  raise DataError, "check executed timestamp must be an integer"
25
25
  end
26
- unless check[:ttl].nil? || (check[:ttl].is_a?(Integer) && check[:ttl] > 0)
27
- raise DataError, "check ttl must be an integer greater than 0"
28
- end
29
26
  end
30
27
 
31
28
  # Process a check result. Set check result attribute defaults,
@@ -0,0 +1,46 @@
1
+ require "sensu/settings/rules"
2
+ require "sensu/settings/validators/check"
3
+
4
+ module Sensu
5
+ module Client
6
+ module Validators
7
+ class Check
8
+ # Include Sensu Settings rules and check validator.
9
+ include Sensu::Settings::Rules
10
+ include Sensu::Settings::Validators::Check
11
+
12
+ attr_reader :failures
13
+
14
+ def initialize
15
+ @failures = []
16
+ end
17
+
18
+ # Determine if a check definition is valid.
19
+ #
20
+ # @param client [Hash]
21
+ # @return [TrueClass, FalseClass]
22
+ def valid?(check)
23
+ validate_check_name(check)
24
+ validate_check_source(check) if check[:source]
25
+ validate_check_handling(check)
26
+ validate_check_ttl(check) if check[:ttl]
27
+ validate_check_aggregate(check)
28
+ validate_check_flap_detection(check)
29
+ @failures.empty?
30
+ end
31
+
32
+ private
33
+
34
+ # This method is called when `validate_check()` encounters an
35
+ # invalid definition object. This method adds definition
36
+ # validation failures to `@failures`.
37
+ def invalid(object, message)
38
+ @failures << {
39
+ :object => object,
40
+ :message => message
41
+ }
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -1,7 +1,12 @@
1
1
  module Sensu
2
2
  unless defined?(Sensu::VERSION)
3
3
  # Sensu release version.
4
- VERSION = "0.29.0".freeze
4
+ VERSION = "1.0.0.alpha.1".freeze
5
+
6
+ # Sensu release information.
7
+ RELEASE_INFO = {
8
+ :version => VERSION
9
+ }
5
10
 
6
11
  # Sensu check severities.
7
12
  SEVERITIES = %w[ok warning critical unknown].freeze
data/lib/sensu/daemon.rb CHANGED
@@ -4,12 +4,12 @@ gem "eventmachine", "1.2.2"
4
4
 
5
5
  gem "sensu-json", "2.1.0"
6
6
  gem "sensu-logger", "1.2.1"
7
- gem "sensu-settings", "10.0.0"
7
+ gem "sensu-settings", "10.2.0"
8
8
  gem "sensu-extension", "1.5.1"
9
9
  gem "sensu-extensions", "1.9.0"
10
10
  gem "sensu-transport", "7.0.2"
11
11
  gem "sensu-spawn", "2.2.1"
12
- gem "sensu-redis", "2.1.1"
12
+ gem "sensu-redis", "2.2.0"
13
13
 
14
14
  require "time"
15
15
  require "uri"
@@ -38,8 +38,11 @@ module Sensu
38
38
  # handle, using the definition attribute `:severities`. The
39
39
  # possible severities are "ok", "warning", "critical", and
40
40
  # "unknown". Handler severity filtering is bypassed when the
41
- # event `:action` is `:resolve`, if the check history contains
42
- # one of the specified severities since the last OK result.
41
+ # event `:action` is `:resolve` and a previous check history
42
+ # status identifies a severity specified in the handler
43
+ # definition. It's possible for a check history status of 0 to
44
+ # have had the flapping action, so we are unable to consider
45
+ # every past 0 to indicate a resolution.
43
46
  #
44
47
  # @param handler [Hash] definition.
45
48
  # @param event [Hash]
@@ -48,10 +51,7 @@ module Sensu
48
51
  if handler.has_key?(:severities)
49
52
  case event[:action]
50
53
  when :resolve
51
- event[:check][:history].reverse[1..-1].any? do |status|
52
- if status.to_i == 0
53
- break false
54
- end
54
+ event[:check][:history].any? do |status|
55
55
  severity = SEVERITIES[status.to_i] || "unknown"
56
56
  handler[:severities].include?(severity)
57
57
  end
@@ -434,11 +434,18 @@ module Sensu
434
434
  # @return [TrueClass, FalseClass]
435
435
  def check_flapping?(stored_event, check)
436
436
  if check.has_key?(:low_flap_threshold) && check.has_key?(:high_flap_threshold)
437
- was_flapping = stored_event && stored_event[:action] == EVENT_FLAPPING_ACTION
438
- if was_flapping
439
- check[:total_state_change] > check[:low_flap_threshold]
437
+ if check[:low_flap_threshold].is_a?(Integer) && check[:high_flap_threshold].is_a?(Integer)
438
+ was_flapping = stored_event && stored_event[:action] == EVENT_FLAPPING_ACTION
439
+ if was_flapping
440
+ check[:total_state_change] > check[:low_flap_threshold]
441
+ else
442
+ check[:total_state_change] >= check[:high_flap_threshold]
443
+ end
440
444
  else
441
- check[:total_state_change] >= check[:high_flap_threshold]
445
+ details = {:check => check}
446
+ details[:client] = stored_event[:client] if stored_event
447
+ @logger.error("invalid check flap thresholds", details)
448
+ false
442
449
  end
443
450
  else
444
451
  false
@@ -1290,6 +1297,11 @@ module Sensu
1290
1297
  def update_server_registry
1291
1298
  @logger.debug("updating the server registry")
1292
1299
  process_cpu_times do |cpu_user, cpu_system, _, _|
1300
+ sensu = RELEASE_INFO.merge(
1301
+ :settings => {
1302
+ :hexdigest => @settings.hexdigest
1303
+ }
1304
+ )
1293
1305
  info = {
1294
1306
  :id => server_id,
1295
1307
  :hostname => system_hostname,
@@ -1301,12 +1313,7 @@ module Sensu
1301
1313
  :system => cpu_system
1302
1314
  }
1303
1315
  },
1304
- :sensu => {
1305
- :version => VERSION,
1306
- :settings => {
1307
- :hexdigest => @settings.hexdigest
1308
- }
1309
- },
1316
+ :sensu => sensu,
1310
1317
  :timestamp => Time.now.to_i
1311
1318
  }
1312
1319
  @redis.sadd("servers", server_id)
data/sensu.gemspec CHANGED
@@ -15,12 +15,12 @@ Gem::Specification.new do |s|
15
15
  s.add_dependency "eventmachine", "1.2.2"
16
16
  s.add_dependency "sensu-json", "2.1.0"
17
17
  s.add_dependency "sensu-logger", "1.2.1"
18
- s.add_dependency "sensu-settings", "10.0.0"
18
+ s.add_dependency "sensu-settings", "10.2.0"
19
19
  s.add_dependency "sensu-extension", "1.5.1"
20
20
  s.add_dependency "sensu-extensions", "1.9.0"
21
21
  s.add_dependency "sensu-transport", "7.0.2"
22
22
  s.add_dependency "sensu-spawn", "2.2.1"
23
- s.add_dependency "sensu-redis", "2.1.1"
23
+ s.add_dependency "sensu-redis", "2.2.0"
24
24
  s.add_dependency "em-http-server", "0.1.8"
25
25
  s.add_dependency "parse-cron", "0.1.4"
26
26
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.29.0
4
+ version: 1.0.0.alpha.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Porter
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2017-03-29 00:00:00.000000000 Z
12
+ date: 2017-06-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: eventmachine
@@ -59,14 +59,14 @@ dependencies:
59
59
  requirements:
60
60
  - - '='
61
61
  - !ruby/object:Gem::Version
62
- version: 10.0.0
62
+ version: 10.2.0
63
63
  type: :runtime
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - '='
68
68
  - !ruby/object:Gem::Version
69
- version: 10.0.0
69
+ version: 10.2.0
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: sensu-extension
72
72
  requirement: !ruby/object:Gem::Requirement
@@ -129,14 +129,14 @@ dependencies:
129
129
  requirements:
130
130
  - - '='
131
131
  - !ruby/object:Gem::Version
132
- version: 2.1.1
132
+ version: 2.2.0
133
133
  type: :runtime
134
134
  prerelease: false
135
135
  version_requirements: !ruby/object:Gem::Requirement
136
136
  requirements:
137
137
  - - '='
138
138
  - !ruby/object:Gem::Version
139
- version: 2.1.1
139
+ version: 2.2.0
140
140
  - !ruby/object:Gem::Dependency
141
141
  name: em-http-server
142
142
  requirement: !ruby/object:Gem::Requirement
@@ -269,6 +269,7 @@ files:
269
269
  - lib/sensu/client/process.rb
270
270
  - lib/sensu/client/socket.rb
271
271
  - lib/sensu/client/utils.rb
272
+ - lib/sensu/client/validators/check.rb
272
273
  - lib/sensu/constants.rb
273
274
  - lib/sensu/daemon.rb
274
275
  - lib/sensu/sandbox.rb
@@ -294,12 +295,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
294
295
  version: '0'
295
296
  required_rubygems_version: !ruby/object:Gem::Requirement
296
297
  requirements:
297
- - - ">="
298
+ - - ">"
298
299
  - !ruby/object:Gem::Version
299
- version: '0'
300
+ version: 1.3.1
300
301
  requirements: []
301
302
  rubyforge_project:
302
- rubygems_version: 2.6.3
303
+ rubygems_version: 2.6.11
303
304
  signing_key:
304
305
  specification_version: 4
305
306
  summary: A monitoring framework