sensu 0.16.0-java → 0.17.0.beta.1-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -0
- data/bin/sensu-api +4 -4
- data/bin/sensu-client +4 -4
- data/bin/sensu-server +4 -4
- data/lib/sensu/api/process.rb +704 -0
- data/lib/sensu/cli.rb +21 -15
- data/lib/sensu/client/process.rb +414 -0
- data/lib/sensu/client/socket.rb +226 -0
- data/lib/sensu/constants.rb +4 -1
- data/lib/sensu/daemon.rb +125 -73
- data/lib/sensu/redis.rb +10 -5
- data/lib/sensu/server/filter.rb +309 -0
- data/lib/sensu/server/handle.rb +168 -0
- data/lib/sensu/server/mutate.rb +92 -0
- data/lib/sensu/server/process.rb +811 -0
- data/lib/sensu/server/sandbox.rb +21 -0
- data/lib/sensu/server/socket.rb +42 -0
- data/lib/sensu/utilities.rb +29 -3
- data/sensu.gemspec +29 -28
- metadata +34 -16
- data/lib/sensu/api.rb +0 -704
- data/lib/sensu/client.rb +0 -292
- data/lib/sensu/sandbox.rb +0 -11
- data/lib/sensu/server.rb +0 -767
- data/lib/sensu/socket.rb +0 -246
@@ -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
|
data/lib/sensu/utilities.rb
CHANGED
@@ -1,13 +1,22 @@
|
|
1
|
-
gem
|
1
|
+
gem "uuidtools", "2.1.4"
|
2
2
|
|
3
|
-
require
|
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) ==
|
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__),
|
2
|
+
require File.join(File.dirname(__FILE__), "lib", "sensu", "constants")
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
|
-
s.name =
|
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 = [
|
9
|
-
s.email = [
|
10
|
-
s.homepage =
|
11
|
-
s.summary =
|
12
|
-
s.description =
|
13
|
-
s.license =
|
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
|
17
|
-
s.add_dependency
|
18
|
-
s.add_dependency
|
19
|
-
s.add_dependency
|
20
|
-
s.add_dependency
|
21
|
-
s.add_dependency
|
22
|
-
s.add_dependency
|
23
|
-
s.add_dependency
|
24
|
-
s.add_dependency
|
25
|
-
s.add_dependency
|
26
|
-
s.add_dependency
|
27
|
-
s.add_dependency
|
28
|
-
s.add_dependency
|
29
|
-
s.add_dependency
|
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
|
32
|
-
s.add_development_dependency
|
33
|
-
s.add_development_dependency
|
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(
|
36
|
-
s.executables = Dir.glob(
|
37
|
-
s.require_paths = [
|
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.
|
4
|
+
version: 0.17.0.beta.1
|
5
5
|
platform: java
|
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:
|
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,18 +39,32 @@ dependencies:
|
|
39
39
|
version: 2.1.4
|
40
40
|
prerelease: false
|
41
41
|
type: :runtime
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: eventmachine
|
44
|
+
version_requirements: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - '='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 1.0.3
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - '='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 1.0.3
|
54
|
+
prerelease: false
|
55
|
+
type: :runtime
|
42
56
|
- !ruby/object:Gem::Dependency
|
43
57
|
name: sensu-em
|
44
58
|
version_requirements: !ruby/object:Gem::Requirement
|
45
59
|
requirements:
|
46
60
|
- - '='
|
47
61
|
- !ruby/object:Gem::Version
|
48
|
-
version: 2.4.
|
62
|
+
version: 2.4.1
|
49
63
|
requirement: !ruby/object:Gem::Requirement
|
50
64
|
requirements:
|
51
65
|
- - '='
|
52
66
|
- !ruby/object:Gem::Version
|
53
|
-
version: 2.4.
|
67
|
+
version: 2.4.1
|
54
68
|
prerelease: false
|
55
69
|
type: :runtime
|
56
70
|
- !ruby/object:Gem::Dependency
|
@@ -87,12 +101,12 @@ dependencies:
|
|
87
101
|
requirements:
|
88
102
|
- - '='
|
89
103
|
- !ruby/object:Gem::Version
|
90
|
-
version: 1.
|
104
|
+
version: 1.1.2
|
91
105
|
requirement: !ruby/object:Gem::Requirement
|
92
106
|
requirements:
|
93
107
|
- - '='
|
94
108
|
- !ruby/object:Gem::Version
|
95
|
-
version: 1.
|
109
|
+
version: 1.1.2
|
96
110
|
prerelease: false
|
97
111
|
type: :runtime
|
98
112
|
- !ruby/object:Gem::Dependency
|
@@ -101,12 +115,12 @@ dependencies:
|
|
101
115
|
requirements:
|
102
116
|
- - '='
|
103
117
|
- !ruby/object:Gem::Version
|
104
|
-
version: 1.
|
118
|
+
version: 1.1.0
|
105
119
|
requirement: !ruby/object:Gem::Requirement
|
106
120
|
requirements:
|
107
121
|
- - '='
|
108
122
|
- !ruby/object:Gem::Version
|
109
|
-
version: 1.
|
123
|
+
version: 1.1.0
|
110
124
|
prerelease: false
|
111
125
|
type: :runtime
|
112
126
|
- !ruby/object:Gem::Dependency
|
@@ -224,7 +238,7 @@ dependencies:
|
|
224
238
|
description: A monitoring framework that aims to be simple, malleable, and scalable.
|
225
239
|
email:
|
226
240
|
- portertech@gmail.com
|
227
|
-
-
|
241
|
+
- amdprophet@gmail.com
|
228
242
|
executables:
|
229
243
|
- sensu-server
|
230
244
|
- sensu-client
|
@@ -236,16 +250,20 @@ files:
|
|
236
250
|
- bin/sensu-client
|
237
251
|
- bin/sensu-api
|
238
252
|
- lib/sensu.rb
|
239
|
-
- lib/sensu/socket.rb
|
240
|
-
- lib/sensu/server.rb
|
241
253
|
- lib/sensu/constants.rb
|
242
|
-
- lib/sensu/client.rb
|
243
|
-
- lib/sensu/sandbox.rb
|
244
254
|
- lib/sensu/daemon.rb
|
245
255
|
- lib/sensu/cli.rb
|
246
256
|
- lib/sensu/redis.rb
|
247
257
|
- lib/sensu/utilities.rb
|
248
|
-
- lib/sensu/
|
258
|
+
- lib/sensu/client/socket.rb
|
259
|
+
- lib/sensu/client/process.rb
|
260
|
+
- lib/sensu/server/handle.rb
|
261
|
+
- lib/sensu/server/socket.rb
|
262
|
+
- lib/sensu/server/sandbox.rb
|
263
|
+
- lib/sensu/server/process.rb
|
264
|
+
- lib/sensu/server/mutate.rb
|
265
|
+
- lib/sensu/server/filter.rb
|
266
|
+
- lib/sensu/api/process.rb
|
249
267
|
- sensu.gemspec
|
250
268
|
- README.md
|
251
269
|
- CHANGELOG.md
|
@@ -265,9 +283,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
265
283
|
version: '0'
|
266
284
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
267
285
|
requirements:
|
268
|
-
- - '
|
286
|
+
- - '>'
|
269
287
|
- !ruby/object:Gem::Version
|
270
|
-
version:
|
288
|
+
version: 1.3.1
|
271
289
|
requirements: []
|
272
290
|
rubyforge_project:
|
273
291
|
rubygems_version: 2.1.9
|