sensu 0.9.8 → 0.9.9.beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +18 -0
- data/lib/sensu/api.rb +38 -15
- data/lib/sensu/client.rb +2 -2
- data/lib/sensu/constants.rb +1 -1
- data/lib/sensu/server.rb +32 -18
- data/lib/sensu/settings.rb +7 -0
- metadata +12 -9
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,21 @@
|
|
1
|
+
## 0.9.9 - TBD
|
2
|
+
|
3
|
+
### Features
|
4
|
+
|
5
|
+
RabbitMQ keepalives & results queue message and consumer counts available
|
6
|
+
via the API (/info).
|
7
|
+
|
8
|
+
Aggregate results available via the API when using a parameter
|
9
|
+
(?results=true).
|
10
|
+
|
11
|
+
### Other
|
12
|
+
|
13
|
+
Server is now using basic AMQP QoS (prefetch), just enough back pressure.
|
14
|
+
|
15
|
+
Fixed server execute command method error handling.
|
16
|
+
|
17
|
+
Events with a resolve action bypass handler severity filtering.
|
18
|
+
|
1
19
|
## 0.9.8 - 2012-11-15
|
2
20
|
|
3
21
|
### Features
|
data/lib/sensu/api.rb
CHANGED
@@ -229,12 +229,34 @@ module Sensu
|
|
229
229
|
:sensu => {
|
230
230
|
:version => Sensu::VERSION
|
231
231
|
},
|
232
|
+
:rabbitmq => {
|
233
|
+
:keepalives => {
|
234
|
+
:messages => nil,
|
235
|
+
:consumers => nil
|
236
|
+
},
|
237
|
+
:results => {
|
238
|
+
:messages => nil,
|
239
|
+
:consumers => nil
|
240
|
+
}
|
241
|
+
},
|
232
242
|
:health => {
|
233
243
|
:redis => $redis.connected? ? 'ok' : 'down',
|
234
244
|
:rabbitmq => $rabbitmq.connected? ? 'ok' : 'down'
|
235
245
|
}
|
236
246
|
}
|
237
|
-
|
247
|
+
if $rabbitmq.connected?
|
248
|
+
$amq.queue('keepalives').status do |messages, consumers|
|
249
|
+
response[:rabbitmq][:keepalives][:messages] = messages
|
250
|
+
response[:rabbitmq][:keepalives][:consumers] = consumers
|
251
|
+
$amq.queue('results').status do |messages, consumers|
|
252
|
+
response[:rabbitmq][:results][:messages] = messages
|
253
|
+
response[:rabbitmq][:results][:consumers] = consumers
|
254
|
+
body response.to_json
|
255
|
+
end
|
256
|
+
end
|
257
|
+
else
|
258
|
+
body response.to_json
|
259
|
+
end
|
238
260
|
end
|
239
261
|
|
240
262
|
aget '/clients' do
|
@@ -449,27 +471,28 @@ module Sensu
|
|
449
471
|
result_set = check_name + ':' + check_issued
|
450
472
|
$redis.hgetall('aggregate:' + result_set).callback do |aggregate|
|
451
473
|
unless aggregate.empty?
|
452
|
-
response = aggregate.inject(Hash.new) do |
|
453
|
-
|
454
|
-
|
474
|
+
response = aggregate.inject(Hash.new) do |totals, (status, count)|
|
475
|
+
totals[status] = Integer(count)
|
476
|
+
totals
|
455
477
|
end
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
478
|
+
$redis.hgetall('aggregation:' + result_set).callback do |results|
|
479
|
+
parsed_results = results.inject(Array.new) do |parsed, (client_name, check_json)|
|
480
|
+
check = JSON.parse(check_json, :symbolize_names => true)
|
481
|
+
parsed.push(check.merge(:client => client_name))
|
482
|
+
end
|
483
|
+
if params[:summarize]
|
484
|
+
options = params[:summarize].split(',')
|
463
485
|
if options.include?('output')
|
464
486
|
outputs = Hash.new(0)
|
465
|
-
|
466
|
-
outputs[
|
487
|
+
parsed_results.each do |result|
|
488
|
+
outputs[result[:output]] += 1
|
467
489
|
end
|
468
490
|
response[:outputs] = outputs
|
469
491
|
end
|
470
|
-
body response.to_json
|
471
492
|
end
|
472
|
-
|
493
|
+
if params[:results]
|
494
|
+
response[:results] = parsed_results
|
495
|
+
end
|
473
496
|
body response.to_json
|
474
497
|
end
|
475
498
|
else
|
data/lib/sensu/client.rb
CHANGED
@@ -186,10 +186,10 @@ module Sensu
|
|
186
186
|
def setup_standalone
|
187
187
|
@logger.debug('scheduling standalone checks')
|
188
188
|
standalone_check_count = 0
|
189
|
-
stagger = testing? ? 0 :
|
189
|
+
stagger = testing? ? 0 : 2
|
190
190
|
@settings.checks.each do |check|
|
191
191
|
if check[:standalone]
|
192
|
-
standalone_check_count
|
192
|
+
standalone_check_count = (standalone_check_count + 1) % 30
|
193
193
|
@timers << EM::Timer.new(stagger * standalone_check_count) do
|
194
194
|
interval = testing? ? 0.5 : check[:interval]
|
195
195
|
@timers << EM::PeriodicTimer.new(interval) do
|
data/lib/sensu/constants.rb
CHANGED
data/lib/sensu/server.rb
CHANGED
@@ -76,6 +76,7 @@ module Sensu
|
|
76
76
|
end
|
77
77
|
@amq = AMQP::Channel.new(@rabbitmq)
|
78
78
|
@amq.auto_recovery = true
|
79
|
+
@amq.prefetch(1)
|
79
80
|
@amq.on_error do |channel, channel_close|
|
80
81
|
@logger.fatal('rabbitmq channel closed', {
|
81
82
|
:error => {
|
@@ -90,13 +91,15 @@ module Sensu
|
|
90
91
|
def setup_keepalives
|
91
92
|
@logger.debug('subscribing to keepalives')
|
92
93
|
@keepalive_queue = @amq.queue('keepalives')
|
93
|
-
@keepalive_queue.subscribe do |payload|
|
94
|
+
@keepalive_queue.subscribe(:ack => true) do |header, payload|
|
94
95
|
client = JSON.parse(payload, :symbolize_names => true)
|
95
96
|
@logger.debug('received keepalive', {
|
96
97
|
:client => client
|
97
98
|
})
|
98
99
|
@redis.set('client:' + client[:name], client.to_json).callback do
|
99
|
-
@redis.sadd('clients', client[:name])
|
100
|
+
@redis.sadd('clients', client[:name]).callback do
|
101
|
+
header.ack
|
102
|
+
end
|
100
103
|
end
|
101
104
|
end
|
102
105
|
end
|
@@ -164,14 +167,16 @@ module Sensu
|
|
164
167
|
handlers = derive_handlers(handler_list)
|
165
168
|
event_severity = Sensu::SEVERITIES[event[:check][:status]] || 'unknown'
|
166
169
|
handlers.select do |handler|
|
167
|
-
if
|
168
|
-
@logger.
|
170
|
+
if check_subdued?(event[:check], :handler)
|
171
|
+
@logger.info('check is subdued at handler', {
|
169
172
|
:event => event,
|
170
173
|
:handler => handler
|
171
174
|
})
|
172
175
|
false
|
173
|
-
elsif
|
174
|
-
|
176
|
+
elsif event[:action] == :resolve
|
177
|
+
true
|
178
|
+
elsif handler.has_key?(:severities) && !handler[:severities].include?(event_severity)
|
179
|
+
@logger.debug('handler does not handle event severity', {
|
175
180
|
:event => event,
|
176
181
|
:handler => handler
|
177
182
|
})
|
@@ -183,10 +188,16 @@ module Sensu
|
|
183
188
|
end
|
184
189
|
|
185
190
|
def execute_command(command, data=nil, on_error=nil, &block)
|
191
|
+
on_error ||= Proc.new do |error|
|
192
|
+
@logger.error('failed to execute command', {
|
193
|
+
:command => command,
|
194
|
+
:data => data,
|
195
|
+
:error => error.to_s
|
196
|
+
})
|
197
|
+
end
|
186
198
|
execute = Proc.new do
|
187
|
-
output = ''
|
188
|
-
status = 0
|
189
199
|
begin
|
200
|
+
output = ''
|
190
201
|
IO.popen(command + ' 2>&1', 'r+') do |io|
|
191
202
|
unless data.nil?
|
192
203
|
io.write(data.to_s)
|
@@ -195,16 +206,16 @@ module Sensu
|
|
195
206
|
output = io.read
|
196
207
|
end
|
197
208
|
status = $?.exitstatus
|
209
|
+
[true, output, status]
|
198
210
|
rescue => error
|
199
|
-
|
200
|
-
|
201
|
-
on_error.call(error)
|
202
|
-
end
|
211
|
+
on_error.call(error)
|
212
|
+
[false, nil, nil]
|
203
213
|
end
|
204
|
-
[output, status]
|
205
214
|
end
|
206
|
-
complete = Proc.new do |output, status|
|
207
|
-
|
215
|
+
complete = Proc.new do |success, output, status|
|
216
|
+
if success
|
217
|
+
block.call(output, status)
|
218
|
+
end
|
208
219
|
end
|
209
220
|
EM::defer(execute, complete)
|
210
221
|
end
|
@@ -434,12 +445,15 @@ module Sensu
|
|
434
445
|
def setup_results
|
435
446
|
@logger.debug('subscribing to results')
|
436
447
|
@result_queue = @amq.queue('results')
|
437
|
-
@result_queue.subscribe do |payload|
|
448
|
+
@result_queue.subscribe(:ack => true) do |header, payload|
|
438
449
|
result = JSON.parse(payload, :symbolize_names => true)
|
439
450
|
@logger.debug('received result', {
|
440
451
|
:result => result
|
441
452
|
})
|
442
453
|
process_result(result)
|
454
|
+
EM::next_tick do
|
455
|
+
header.ack
|
456
|
+
end
|
443
457
|
end
|
444
458
|
end
|
445
459
|
|
@@ -461,10 +475,10 @@ module Sensu
|
|
461
475
|
def setup_publisher
|
462
476
|
@logger.debug('scheduling check requests')
|
463
477
|
check_count = 0
|
464
|
-
stagger = testing? ? 0 :
|
478
|
+
stagger = testing? ? 0 : 2
|
465
479
|
@settings.checks.each do |check|
|
466
480
|
unless check[:publish] == false || check[:standalone]
|
467
|
-
check_count
|
481
|
+
check_count = (check_count + 1) % 30
|
468
482
|
@master_timers << EM::Timer.new(stagger * check_count) do
|
469
483
|
interval = testing? ? 0.5 : check[:interval]
|
470
484
|
@master_timers << EM::PeriodicTimer.new(interval) do
|
data/lib/sensu/settings.rb
CHANGED
@@ -388,6 +388,13 @@ module Sensu
|
|
388
388
|
:handler => handler
|
389
389
|
})
|
390
390
|
end
|
391
|
+
handler[:handlers].each do |handler_name|
|
392
|
+
unless handler_name.is_a?(String)
|
393
|
+
invalid('handler set handlers must be strings', {
|
394
|
+
:handler => handler
|
395
|
+
})
|
396
|
+
end
|
397
|
+
end
|
391
398
|
else
|
392
399
|
invalid('unknown handler type', {
|
393
400
|
:handler => handler
|
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: -1732117756
|
5
|
+
prerelease: true
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 9
|
9
|
-
-
|
10
|
-
|
9
|
+
- 9
|
10
|
+
- beta
|
11
|
+
version: 0.9.9.beta
|
11
12
|
platform: ruby
|
12
13
|
authors:
|
13
14
|
- Sean Porter
|
@@ -16,7 +17,7 @@ autorequire:
|
|
16
17
|
bindir: bin
|
17
18
|
cert_chain: []
|
18
19
|
|
19
|
-
date: 2012-11-
|
20
|
+
date: 2012-11-27 00:00:00 -08:00
|
20
21
|
default_executable:
|
21
22
|
dependencies:
|
22
23
|
- !ruby/object:Gem::Dependency
|
@@ -224,12 +225,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
224
225
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
225
226
|
none: false
|
226
227
|
requirements:
|
227
|
-
- - "
|
228
|
+
- - ">"
|
228
229
|
- !ruby/object:Gem::Version
|
229
|
-
hash:
|
230
|
+
hash: 25
|
230
231
|
segments:
|
231
|
-
-
|
232
|
-
|
232
|
+
- 1
|
233
|
+
- 3
|
234
|
+
- 1
|
235
|
+
version: 1.3.1
|
233
236
|
requirements: []
|
234
237
|
|
235
238
|
rubyforge_project:
|