sensu 0.17.0.beta → 0.17.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,21 @@
1
+ module Sensu
2
+ module Server
3
+ module Sandbox
4
+ # Evaluate a Ruby expression within the context of a simple
5
+ # "sandbox", a Proc in a module method. Use the Ruby `$SAFE`
6
+ # level of 4 when the version of Ruby is less than 2.1.0. A
7
+ # single value is provided to the "sandbox".
8
+ #
9
+ # @param expression [String] to be evaluated.
10
+ # @param value [Object] to provide the "sandbox" with.
11
+ # @return [Object]
12
+ def self.eval(expression, value=nil)
13
+ result = Proc.new do
14
+ $SAFE = (RUBY_VERSION < "2.1.0" ? 4 : 3)
15
+ Kernel.eval(expression)
16
+ end
17
+ result.call
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,42 @@
1
+ module Sensu
2
+ module Server
3
+ class Socket < EM::Connection
4
+ # @!attribute [rw] on_success
5
+ # @return [Proc] callback to be called after the data has been
6
+ # transmitted successfully.
7
+ attr_accessor :on_success
8
+
9
+ # @!attribute [rw] on_error
10
+ # @return [Proc] callback to be called when there is an error.
11
+ attr_accessor :on_error
12
+
13
+ # Record the current time and the inactivity timeout value, when
14
+ # the socket connection is successful. These values are used to
15
+ # determine if the a connection was closed due to the timeout.
16
+ def connection_completed
17
+ @connected_at = Time.now.to_f
18
+ @inactivity_timeout = comm_inactivity_timeout
19
+ end
20
+
21
+ # Determine if the connection and data transmission was
22
+ # successful and call the appropriate callback, `@on_success`
23
+ # or `@on_error`, providing it with a message. The
24
+ # `@connected_at` timestamp indicates that the connection was
25
+ # successful. If the elapsed time is greater than the inactivity
26
+ # timeout value, the connection was closed abruptly by the
27
+ # timeout timer, and the data was not transmitted.
28
+ def unbind
29
+ if @connected_at
30
+ elapsed_time = Time.now.to_f - @connected_at
31
+ if elapsed_time >= @inactivity_timeout
32
+ @on_error.call("socket inactivity timeout")
33
+ else
34
+ @on_success.call("wrote to socket")
35
+ end
36
+ else
37
+ @on_error.call("failed to connect to socket")
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -1,13 +1,22 @@
1
- gem 'uuidtools', '2.1.4'
1
+ gem "uuidtools", "2.1.4"
2
2
 
3
- require 'uuidtools'
3
+ require "uuidtools"
4
4
 
5
5
  module Sensu
6
6
  module Utilities
7
+ # Determine if Sensu is being tested, using the process name.
8
+ # Sensu is being test if the process name is "rspec",
9
+ #
10
+ # @return [TrueClass, FalseClass]
7
11
  def testing?
8
- File.basename($0) == 'rspec'
12
+ File.basename($0) == "rspec"
9
13
  end
10
14
 
15
+ # Retry a code block until it retures true. The first attempt and
16
+ # following retries are delayed.
17
+ #
18
+ # @param wait [Numeric] time to delay block calls.
19
+ # @param block [Proc] to call that needs to return true.
11
20
  def retry_until_true(wait=0.5, &block)
12
21
  EM::Timer.new(wait) do
13
22
  unless block.call
@@ -16,6 +25,12 @@ module Sensu
16
25
  end
17
26
  end
18
27
 
28
+ # Deep merge two hashes. Nested hashes are deep merged, arrays are
29
+ # concatenated and duplicate array items are removed.
30
+ #
31
+ # @param hash_one [Hash]
32
+ # @param hash_two [Hash]
33
+ # @return [Hash] deep merged hash.
19
34
  def deep_merge(hash_one, hash_two)
20
35
  merged = hash_one.dup
21
36
  hash_two.each do |key, value|
@@ -31,10 +46,21 @@ module Sensu
31
46
  merged
32
47
  end
33
48
 
49
+ # Generate a random universally unique identifier.
50
+ #
51
+ # @return [String] random UUID.
34
52
  def random_uuid
35
53
  UUIDTools::UUID.random_create.to_s
36
54
  end
37
55
 
56
+ # Remove sensitive information from a hash (eg. passwords). By
57
+ # default, hash values will be redacted for the following keys:
58
+ # password, passwd, pass, api_key, api_token, access_key,
59
+ # secret_key, private_key, secret
60
+ #
61
+ # @param hash [Hash] to redact sensitive value from.
62
+ # @param keys [Array] that indicate sensitive values.
63
+ # @return [Hash] hash with redacted sensitive values.
38
64
  def redact_sensitive(hash, keys=nil)
39
65
  keys ||= %w[
40
66
  password passwd pass
data/sensu.gemspec CHANGED
@@ -1,38 +1,39 @@
1
1
  # -*- encoding: utf-8 -*-
2
- require File.join(File.dirname(__FILE__), 'lib', 'sensu', 'constants')
2
+ require File.join(File.dirname(__FILE__), "lib", "sensu", "constants")
3
3
 
4
4
  Gem::Specification.new do |s|
5
- s.name = 'sensu'
5
+ s.name = "sensu"
6
6
  s.version = Sensu::VERSION
7
7
  s.platform = RUBY_PLATFORM =~ /java/ ? Gem::Platform::JAVA : Gem::Platform::RUBY
8
- s.authors = ['Sean Porter', 'Justin Kolberg']
9
- s.email = ['portertech@gmail.com', 'justin.kolberg@sonian.net']
10
- s.homepage = 'https://github.com/sensu/sensu'
11
- s.summary = 'A monitoring framework'
12
- s.description = 'A monitoring framework that aims to be simple, malleable, and scalable.'
13
- s.license = 'MIT'
8
+ s.authors = ["Sean Porter", "Justin Kolberg"]
9
+ s.email = ["portertech@gmail.com", "amdprophet@gmail.com"]
10
+ s.homepage = "https://github.com/sensu/sensu"
11
+ s.summary = "A monitoring framework"
12
+ s.description = "A monitoring framework that aims to be simple, malleable, and scalable."
13
+ s.license = "MIT"
14
14
  s.has_rdoc = false
15
15
 
16
- s.add_dependency('json') if RUBY_VERSION < "1.9"
17
- s.add_dependency('multi_json', '1.10.1')
18
- s.add_dependency('uuidtools', '2.1.4')
19
- s.add_dependency('sensu-em', '2.4.1')
20
- s.add_dependency('sensu-logger', '1.0.0')
21
- s.add_dependency('sensu-settings', '1.2.0')
22
- s.add_dependency('sensu-extension', '1.0.0')
23
- s.add_dependency('sensu-extensions', '1.0.0')
24
- s.add_dependency('sensu-transport', '2.4.0')
25
- s.add_dependency('sensu-spawn', '1.1.0')
26
- s.add_dependency('em-redis-unified', '0.5.0')
27
- s.add_dependency('sinatra', '1.3.5')
28
- s.add_dependency('async_sinatra', '1.0.0')
29
- s.add_dependency('thin', '1.5.0') unless RUBY_PLATFORM =~ /java/
16
+ s.add_dependency "json" if RUBY_VERSION < "1.9"
17
+ s.add_dependency "multi_json", "1.10.1"
18
+ s.add_dependency "uuidtools", "2.1.4"
19
+ s.add_dependency "eventmachine", "1.0.3"
20
+ s.add_dependency "sensu-em", "2.4.1"
21
+ s.add_dependency "sensu-logger", "1.0.0"
22
+ s.add_dependency "sensu-settings", "1.2.0"
23
+ s.add_dependency "sensu-extension", "1.1.2"
24
+ s.add_dependency "sensu-extensions", "1.1.0"
25
+ s.add_dependency "sensu-transport", "2.4.0"
26
+ s.add_dependency "sensu-spawn", "1.1.0"
27
+ s.add_dependency "em-redis-unified", "0.5.0"
28
+ s.add_dependency "sinatra", "1.3.5"
29
+ s.add_dependency "async_sinatra", "1.0.0"
30
+ s.add_dependency "thin", "1.5.0" unless RUBY_PLATFORM =~ /java/
30
31
 
31
- s.add_development_dependency('rake', '~> 10.3')
32
- s.add_development_dependency('rspec', '~> 3.0.0')
33
- s.add_development_dependency('em-http-request', '~> 1.1')
32
+ s.add_development_dependency "rake", "~> 10.3"
33
+ s.add_development_dependency "rspec", "~> 3.0.0"
34
+ s.add_development_dependency "em-http-request", "~> 1.1"
34
35
 
35
- s.files = Dir.glob('{bin,lib}/**/*') + %w[sensu.gemspec README.md CHANGELOG.md MIT-LICENSE.txt]
36
- s.executables = Dir.glob('bin/**/*').map { |file| File.basename(file) }
37
- s.require_paths = ['lib']
36
+ s.files = Dir.glob("{bin,lib}/**/*") + %w[sensu.gemspec README.md CHANGELOG.md MIT-LICENSE.txt]
37
+ s.executables = Dir.glob("bin/**/*").map { |file| File.basename(file) }
38
+ s.require_paths = ["lib"]
38
39
  end
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.17.0.beta
4
+ version: 0.17.0.beta.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Porter
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-02-06 00:00:00.000000000 Z
12
+ date: 2015-03-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json
@@ -39,6 +39,20 @@ dependencies:
39
39
  - - '='
40
40
  - !ruby/object:Gem::Version
41
41
  version: 2.1.4
42
+ - !ruby/object:Gem::Dependency
43
+ name: eventmachine
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - '='
47
+ - !ruby/object:Gem::Version
48
+ version: 1.0.3
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - '='
54
+ - !ruby/object:Gem::Version
55
+ version: 1.0.3
42
56
  - !ruby/object:Gem::Dependency
43
57
  name: sensu-em
44
58
  requirement: !ruby/object:Gem::Requirement
@@ -87,28 +101,28 @@ dependencies:
87
101
  requirements:
88
102
  - - '='
89
103
  - !ruby/object:Gem::Version
90
- version: 1.0.0
104
+ version: 1.1.2
91
105
  type: :runtime
92
106
  prerelease: false
93
107
  version_requirements: !ruby/object:Gem::Requirement
94
108
  requirements:
95
109
  - - '='
96
110
  - !ruby/object:Gem::Version
97
- version: 1.0.0
111
+ version: 1.1.2
98
112
  - !ruby/object:Gem::Dependency
99
113
  name: sensu-extensions
100
114
  requirement: !ruby/object:Gem::Requirement
101
115
  requirements:
102
116
  - - '='
103
117
  - !ruby/object:Gem::Version
104
- version: 1.0.0
118
+ version: 1.1.0
105
119
  type: :runtime
106
120
  prerelease: false
107
121
  version_requirements: !ruby/object:Gem::Requirement
108
122
  requirements:
109
123
  - - '='
110
124
  - !ruby/object:Gem::Version
111
- version: 1.0.0
125
+ version: 1.1.0
112
126
  - !ruby/object:Gem::Dependency
113
127
  name: sensu-transport
114
128
  requirement: !ruby/object:Gem::Requirement
@@ -238,7 +252,7 @@ dependencies:
238
252
  description: A monitoring framework that aims to be simple, malleable, and scalable.
239
253
  email:
240
254
  - portertech@gmail.com
241
- - justin.kolberg@sonian.net
255
+ - amdprophet@gmail.com
242
256
  executables:
243
257
  - sensu-server
244
258
  - sensu-client
@@ -253,15 +267,19 @@ files:
253
267
  - bin/sensu-client
254
268
  - bin/sensu-server
255
269
  - lib/sensu.rb
256
- - lib/sensu/api.rb
270
+ - lib/sensu/api/process.rb
257
271
  - lib/sensu/cli.rb
258
- - lib/sensu/client.rb
272
+ - lib/sensu/client/process.rb
273
+ - lib/sensu/client/socket.rb
259
274
  - lib/sensu/constants.rb
260
275
  - lib/sensu/daemon.rb
261
276
  - lib/sensu/redis.rb
262
- - lib/sensu/sandbox.rb
263
- - lib/sensu/server.rb
264
- - lib/sensu/socket.rb
277
+ - lib/sensu/server/filter.rb
278
+ - lib/sensu/server/handle.rb
279
+ - lib/sensu/server/mutate.rb
280
+ - lib/sensu/server/process.rb
281
+ - lib/sensu/server/sandbox.rb
282
+ - lib/sensu/server/socket.rb
265
283
  - lib/sensu/utilities.rb
266
284
  - sensu.gemspec
267
285
  homepage: https://github.com/sensu/sensu