sensu 0.10.2 → 0.11.0.beta
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +25 -0
- data/lib/sensu/cli.rb +8 -0
- data/lib/sensu/client.rb +2 -1
- data/lib/sensu/constants.rb +1 -1
- data/lib/sensu/extensions/handlers/debug.rb +1 -1
- data/lib/sensu/extensions/mutators/only_check_output.rb +1 -1
- data/lib/sensu/extensions.rb +37 -17
- data/lib/sensu/server.rb +4 -3
- metadata +67 -64
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,28 @@
|
|
1
|
+
## 0.11.0 - TBD
|
2
|
+
|
3
|
+
### Non-backwards compatible changes
|
4
|
+
|
5
|
+
WARNING: Extensions compatible with previous versions of Sensu will
|
6
|
+
NO LONGER FUNCTION until they are updated for Sensu 0.11.x! Extensions
|
7
|
+
are an experimental feature and not widely used.
|
8
|
+
|
9
|
+
Sensu settings are now part of the extension API & are no longer passed
|
10
|
+
as an argument to run.
|
11
|
+
|
12
|
+
### Features
|
13
|
+
|
14
|
+
You can specify the Sensu log severity level using the -L (--log_level)
|
15
|
+
CLI argument, providing a valid level (eg. warn).
|
16
|
+
|
17
|
+
### Other
|
18
|
+
|
19
|
+
Sensu passes a dup of event data to mutator & handler extensions to
|
20
|
+
prevent mutation.
|
21
|
+
|
22
|
+
Extension runs are wrapped in a begin/rescue block, a safety net.
|
23
|
+
|
24
|
+
UDP handler now binds to "0.0.0.0".
|
25
|
+
|
1
26
|
## 0.10.2 - 2013-07-18
|
2
27
|
|
3
28
|
### Other
|
data/lib/sensu/cli.rb
CHANGED
@@ -25,6 +25,14 @@ module Sensu
|
|
25
25
|
opts.on('-l', '--log FILE', 'Log to a given FILE. Default: STDOUT') do |file|
|
26
26
|
options[:log_file] = file
|
27
27
|
end
|
28
|
+
opts.on('-L', '--log_level LEVEL', 'Log severity LEVEL') do |level|
|
29
|
+
log_level = level.to_s.downcase.to_sym
|
30
|
+
unless LOG_LEVELS.include?(log_level)
|
31
|
+
puts 'Unknown log level: ' + level.to_s
|
32
|
+
exit 1
|
33
|
+
end
|
34
|
+
options[:log_level] = log_level
|
35
|
+
end
|
28
36
|
opts.on('-v', '--verbose', 'Enable verbose logging') do
|
29
37
|
options[:log_level] = :debug
|
30
38
|
end
|
data/lib/sensu/client.rb
CHANGED
@@ -21,6 +21,7 @@ module Sensu
|
|
21
21
|
@settings = base.settings
|
22
22
|
@extensions = base.extensions
|
23
23
|
base.setup_process
|
24
|
+
@extensions.load_settings(@settings.to_hash)
|
24
25
|
@timers = Array.new
|
25
26
|
@checks_in_progress = Array.new
|
26
27
|
@safe_mode = @settings[:client][:safe_mode] || false
|
@@ -143,7 +144,7 @@ module Sensu
|
|
143
144
|
})
|
144
145
|
check[:executed] = Time.now.to_i
|
145
146
|
extension = @extensions[:checks][check[:name]]
|
146
|
-
extension.
|
147
|
+
extension.safe_run do |output, status|
|
147
148
|
check[:output] = output
|
148
149
|
check[:status] = status
|
149
150
|
publish_result(check)
|
data/lib/sensu/constants.rb
CHANGED
data/lib/sensu/extensions.rb
CHANGED
@@ -53,27 +53,37 @@ module Sensu
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
def
|
57
|
-
|
58
|
-
|
59
|
-
extension
|
60
|
-
end
|
56
|
+
def load_settings(settings={})
|
57
|
+
all_extensions.each do |extension|
|
58
|
+
extension.settings = settings
|
61
59
|
end
|
62
|
-
|
60
|
+
end
|
61
|
+
|
62
|
+
def stop_all(&block)
|
63
|
+
extensions = all_extensions
|
63
64
|
stopper = Proc.new do |extension|
|
64
65
|
if extension.nil?
|
65
66
|
block.call
|
66
67
|
else
|
67
68
|
extension.stop do
|
68
|
-
stopper.call(
|
69
|
+
stopper.call(extensions.pop)
|
69
70
|
end
|
70
71
|
end
|
71
72
|
end
|
72
|
-
stopper.call(
|
73
|
+
stopper.call(extensions.pop)
|
73
74
|
end
|
74
75
|
|
75
76
|
private
|
76
77
|
|
78
|
+
def all_extensions
|
79
|
+
all = @extensions.map do |category, extensions|
|
80
|
+
extensions.map do |name, extension|
|
81
|
+
extension
|
82
|
+
end
|
83
|
+
end
|
84
|
+
all.flatten!
|
85
|
+
end
|
86
|
+
|
77
87
|
def loaded(type, name, description)
|
78
88
|
@logger.info('loaded extension', {
|
79
89
|
:type => type,
|
@@ -85,6 +95,8 @@ module Sensu
|
|
85
95
|
|
86
96
|
module Extension
|
87
97
|
class Base
|
98
|
+
attr_accessor :settings
|
99
|
+
|
88
100
|
def initialize
|
89
101
|
EM::next_tick do
|
90
102
|
post_init
|
@@ -106,19 +118,11 @@ module Sensu
|
|
106
118
|
}
|
107
119
|
end
|
108
120
|
|
109
|
-
def [](key)
|
110
|
-
definition[key.to_sym]
|
111
|
-
end
|
112
|
-
|
113
|
-
def has_key?(key)
|
114
|
-
definition.has_key?(key.to_sym)
|
115
|
-
end
|
116
|
-
|
117
121
|
def post_init
|
118
122
|
true
|
119
123
|
end
|
120
124
|
|
121
|
-
def run(
|
125
|
+
def run(data=nil, &block)
|
122
126
|
block.call('noop', 0)
|
123
127
|
end
|
124
128
|
|
@@ -126,6 +130,22 @@ module Sensu
|
|
126
130
|
block.call
|
127
131
|
end
|
128
132
|
|
133
|
+
def [](key)
|
134
|
+
definition[key.to_sym]
|
135
|
+
end
|
136
|
+
|
137
|
+
def has_key?(key)
|
138
|
+
definition.has_key?(key.to_sym)
|
139
|
+
end
|
140
|
+
|
141
|
+
def safe_run(data=nil, &block)
|
142
|
+
begin
|
143
|
+
data ? run(data.dup, &block) : run(&block)
|
144
|
+
rescue => error
|
145
|
+
block.call(error.to_s, 2)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
129
149
|
def self.descendants
|
130
150
|
ObjectSpace.each_object(Class).select do |klass|
|
131
151
|
klass < self
|
data/lib/sensu/server.rb
CHANGED
@@ -23,6 +23,7 @@ module Sensu
|
|
23
23
|
@settings = base.settings
|
24
24
|
@extensions = base.extensions
|
25
25
|
base.setup_process
|
26
|
+
@extensions.load_settings(@settings.to_hash)
|
26
27
|
@timers = Array.new
|
27
28
|
@master_timers = Array.new
|
28
29
|
@handlers_in_progress_count = 0
|
@@ -293,7 +294,7 @@ module Sensu
|
|
293
294
|
end
|
294
295
|
when @extensions.mutator_exists?(mutator_name)
|
295
296
|
extension = @extensions[:mutators][mutator_name]
|
296
|
-
extension.
|
297
|
+
extension.safe_run(event) do |output, status|
|
297
298
|
if status == 0
|
298
299
|
block.call(output)
|
299
300
|
else
|
@@ -357,7 +358,7 @@ module Sensu
|
|
357
358
|
end
|
358
359
|
when 'udp'
|
359
360
|
begin
|
360
|
-
EM::open_datagram_socket('
|
361
|
+
EM::open_datagram_socket('0.0.0.0', 0, nil) do |socket|
|
361
362
|
socket.send_datagram(event_data.to_s, handler[:socket][:host], handler[:socket][:port])
|
362
363
|
socket.close_connection_after_writing
|
363
364
|
@handlers_in_progress_count -= 1
|
@@ -376,7 +377,7 @@ module Sensu
|
|
376
377
|
end
|
377
378
|
@handlers_in_progress_count -= 1
|
378
379
|
when 'extension'
|
379
|
-
handler.
|
380
|
+
handler.safe_run(event_data) do |output, status|
|
380
381
|
output.split(/\n+/).each do |line|
|
381
382
|
@logger.info(line)
|
382
383
|
end
|
metadata
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: -1487621072
|
5
|
+
prerelease: true
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
|
8
|
+
- 11
|
9
|
+
- 0
|
10
|
+
- beta
|
11
|
+
version: 0.11.0.beta
|
11
12
|
platform: ruby
|
12
13
|
authors:
|
13
14
|
- Sean Porter
|
@@ -16,13 +17,11 @@ autorequire:
|
|
16
17
|
bindir: bin
|
17
18
|
cert_chain: []
|
18
19
|
|
19
|
-
date: 2013-
|
20
|
+
date: 2013-08-14 00:00:00 -07:00
|
20
21
|
default_executable:
|
21
22
|
dependencies:
|
22
23
|
- !ruby/object:Gem::Dependency
|
23
|
-
|
24
|
-
prerelease: false
|
25
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
26
25
|
none: false
|
27
26
|
requirements:
|
28
27
|
- - "="
|
@@ -33,12 +32,12 @@ dependencies:
|
|
33
32
|
- 0
|
34
33
|
- 9
|
35
34
|
version: 2.0.9
|
35
|
+
requirement: *id001
|
36
36
|
type: :runtime
|
37
|
-
|
38
|
-
- !ruby/object:Gem::Dependency
|
39
|
-
name: eventmachine
|
37
|
+
name: oj
|
40
38
|
prerelease: false
|
41
|
-
|
39
|
+
- !ruby/object:Gem::Dependency
|
40
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
42
41
|
none: false
|
43
42
|
requirements:
|
44
43
|
- - "="
|
@@ -49,12 +48,12 @@ dependencies:
|
|
49
48
|
- 0
|
50
49
|
- 3
|
51
50
|
version: 1.0.3
|
51
|
+
requirement: *id002
|
52
52
|
type: :runtime
|
53
|
-
|
54
|
-
- !ruby/object:Gem::Dependency
|
55
|
-
name: amqp
|
53
|
+
name: eventmachine
|
56
54
|
prerelease: false
|
57
|
-
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
58
57
|
none: false
|
59
58
|
requirements:
|
60
59
|
- - "="
|
@@ -65,12 +64,12 @@ dependencies:
|
|
65
64
|
- 9
|
66
65
|
- 10
|
67
66
|
version: 0.9.10
|
67
|
+
requirement: *id003
|
68
68
|
type: :runtime
|
69
|
-
|
70
|
-
- !ruby/object:Gem::Dependency
|
71
|
-
name: em-redis-unified
|
69
|
+
name: amqp
|
72
70
|
prerelease: false
|
73
|
-
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
74
73
|
none: false
|
75
74
|
requirements:
|
76
75
|
- - "="
|
@@ -81,12 +80,12 @@ dependencies:
|
|
81
80
|
- 4
|
82
81
|
- 1
|
83
82
|
version: 0.4.1
|
83
|
+
requirement: *id004
|
84
84
|
type: :runtime
|
85
|
-
|
86
|
-
- !ruby/object:Gem::Dependency
|
87
|
-
name: thin
|
85
|
+
name: em-redis-unified
|
88
86
|
prerelease: false
|
89
|
-
|
87
|
+
- !ruby/object:Gem::Dependency
|
88
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
90
89
|
none: false
|
91
90
|
requirements:
|
92
91
|
- - "="
|
@@ -97,12 +96,12 @@ dependencies:
|
|
97
96
|
- 5
|
98
97
|
- 0
|
99
98
|
version: 1.5.0
|
99
|
+
requirement: *id005
|
100
100
|
type: :runtime
|
101
|
-
|
102
|
-
- !ruby/object:Gem::Dependency
|
103
|
-
name: sinatra
|
101
|
+
name: thin
|
104
102
|
prerelease: false
|
105
|
-
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
106
105
|
none: false
|
107
106
|
requirements:
|
108
107
|
- - "="
|
@@ -113,12 +112,12 @@ dependencies:
|
|
113
112
|
- 3
|
114
113
|
- 5
|
115
114
|
version: 1.3.5
|
115
|
+
requirement: *id006
|
116
116
|
type: :runtime
|
117
|
-
|
118
|
-
- !ruby/object:Gem::Dependency
|
119
|
-
name: async_sinatra
|
117
|
+
name: sinatra
|
120
118
|
prerelease: false
|
121
|
-
|
119
|
+
- !ruby/object:Gem::Dependency
|
120
|
+
version_requirements: &id007 !ruby/object:Gem::Requirement
|
122
121
|
none: false
|
123
122
|
requirements:
|
124
123
|
- - "="
|
@@ -129,12 +128,12 @@ dependencies:
|
|
129
128
|
- 0
|
130
129
|
- 0
|
131
130
|
version: 1.0.0
|
131
|
+
requirement: *id007
|
132
132
|
type: :runtime
|
133
|
-
|
134
|
-
- !ruby/object:Gem::Dependency
|
135
|
-
name: rake
|
133
|
+
name: async_sinatra
|
136
134
|
prerelease: false
|
137
|
-
|
135
|
+
- !ruby/object:Gem::Dependency
|
136
|
+
version_requirements: &id008 !ruby/object:Gem::Requirement
|
138
137
|
none: false
|
139
138
|
requirements:
|
140
139
|
- - ">="
|
@@ -143,12 +142,12 @@ dependencies:
|
|
143
142
|
segments:
|
144
143
|
- 0
|
145
144
|
version: "0"
|
145
|
+
requirement: *id008
|
146
146
|
type: :development
|
147
|
-
|
148
|
-
- !ruby/object:Gem::Dependency
|
149
|
-
name: rspec
|
147
|
+
name: rake
|
150
148
|
prerelease: false
|
151
|
-
|
149
|
+
- !ruby/object:Gem::Dependency
|
150
|
+
version_requirements: &id009 !ruby/object:Gem::Requirement
|
152
151
|
none: false
|
153
152
|
requirements:
|
154
153
|
- - ">="
|
@@ -157,12 +156,12 @@ dependencies:
|
|
157
156
|
segments:
|
158
157
|
- 0
|
159
158
|
version: "0"
|
159
|
+
requirement: *id009
|
160
160
|
type: :development
|
161
|
-
|
162
|
-
- !ruby/object:Gem::Dependency
|
163
|
-
name: em-http-request
|
161
|
+
name: rspec
|
164
162
|
prerelease: false
|
165
|
-
|
163
|
+
- !ruby/object:Gem::Dependency
|
164
|
+
version_requirements: &id010 !ruby/object:Gem::Requirement
|
166
165
|
none: false
|
167
166
|
requirements:
|
168
167
|
- - ">="
|
@@ -171,42 +170,44 @@ dependencies:
|
|
171
170
|
segments:
|
172
171
|
- 0
|
173
172
|
version: "0"
|
173
|
+
requirement: *id010
|
174
174
|
type: :development
|
175
|
-
|
175
|
+
name: em-http-request
|
176
|
+
prerelease: false
|
176
177
|
description: A monitoring framework that aims to be simple, malleable, and scalable. Uses the publish/subscribe model.
|
177
178
|
email:
|
178
179
|
- portertech@gmail.com
|
179
180
|
- justin.kolberg@sonian.net
|
180
181
|
executables:
|
181
182
|
- sensu-api
|
182
|
-
- sensu-server
|
183
183
|
- sensu-client
|
184
|
+
- sensu-server
|
184
185
|
extensions: []
|
185
186
|
|
186
187
|
extra_rdoc_files: []
|
187
188
|
|
188
189
|
files:
|
189
190
|
- bin/sensu-api
|
190
|
-
- bin/sensu-server
|
191
191
|
- bin/sensu-client
|
192
|
-
-
|
193
|
-
- lib/sensu/constants.rb
|
192
|
+
- bin/sensu-server
|
194
193
|
- lib/sensu/api.rb
|
195
|
-
- lib/sensu/
|
196
|
-
- lib/sensu/
|
197
|
-
- lib/sensu/redis.rb
|
198
|
-
- lib/sensu/server.rb
|
199
|
-
- lib/sensu/utilities.rb
|
194
|
+
- lib/sensu/base.rb
|
195
|
+
- lib/sensu/cli.rb
|
200
196
|
- lib/sensu/client.rb
|
201
|
-
- lib/sensu/
|
202
|
-
- lib/sensu/process.rb
|
197
|
+
- lib/sensu/constants.rb
|
203
198
|
- lib/sensu/extensions/handlers/debug.rb
|
204
199
|
- lib/sensu/extensions/mutators/only_check_output.rb
|
205
|
-
- lib/sensu/cli.rb
|
206
|
-
- lib/sensu/logstream.rb
|
207
200
|
- lib/sensu/extensions.rb
|
208
201
|
- lib/sensu/io.rb
|
209
|
-
- lib/sensu/
|
202
|
+
- lib/sensu/logstream.rb
|
203
|
+
- lib/sensu/process.rb
|
204
|
+
- lib/sensu/rabbitmq.rb
|
205
|
+
- lib/sensu/redis.rb
|
206
|
+
- lib/sensu/sandbox.rb
|
207
|
+
- lib/sensu/server.rb
|
208
|
+
- lib/sensu/settings.rb
|
209
|
+
- lib/sensu/socket.rb
|
210
|
+
- lib/sensu/utilities.rb
|
210
211
|
- lib/sensu.rb
|
211
212
|
- sensu.gemspec
|
212
213
|
- README.md
|
@@ -233,12 +234,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
233
234
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
234
235
|
none: false
|
235
236
|
requirements:
|
236
|
-
- - "
|
237
|
+
- - ">"
|
237
238
|
- !ruby/object:Gem::Version
|
238
|
-
hash:
|
239
|
+
hash: 25
|
239
240
|
segments:
|
240
|
-
-
|
241
|
-
|
241
|
+
- 1
|
242
|
+
- 3
|
243
|
+
- 1
|
244
|
+
version: 1.3.1
|
242
245
|
requirements: []
|
243
246
|
|
244
247
|
rubyforge_project:
|