sensu 0.9.6.beta.1 → 0.9.6.beta.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/sensu/base.rb +1 -0
- data/lib/sensu/constants.rb +1 -1
- data/lib/sensu/server.rb +37 -32
- data/lib/sensu/settings.rb +4 -0
- metadata +3 -3
data/lib/sensu/base.rb
CHANGED
data/lib/sensu/constants.rb
CHANGED
data/lib/sensu/server.rb
CHANGED
@@ -312,44 +312,49 @@ module Sensu
|
|
312
312
|
end
|
313
313
|
end
|
314
314
|
|
315
|
+
def publish_result(client, check)
|
316
|
+
payload = {
|
317
|
+
:client => client[:name],
|
318
|
+
:check => check
|
319
|
+
}
|
320
|
+
@logger.info('publishing check result', {
|
321
|
+
:payload => payload
|
322
|
+
})
|
323
|
+
@amq.queue('results').publish(payload.to_json)
|
324
|
+
end
|
325
|
+
|
315
326
|
def setup_keepalive_monitor
|
316
327
|
@logger.debug('monitoring client keepalives')
|
317
328
|
@timers << EM::PeriodicTimer.new(30) do
|
318
|
-
@
|
319
|
-
|
320
|
-
clients.
|
321
|
-
|
322
|
-
client
|
323
|
-
|
324
|
-
|
325
|
-
case
|
326
|
-
when time_since_last_keepalive >= 180
|
327
|
-
check[:output] = 'No keep-alive sent from host in over 180 seconds'
|
328
|
-
check[:status] = 2
|
329
|
-
when time_since_last_keepalive >= 120
|
330
|
-
check[:output] = 'No keep-alive sent from host in over 120 seconds'
|
331
|
-
check[:status] = 1
|
332
|
-
else
|
333
|
-
@redis.hexists('events:' + client[:name], 'keepalive').callback do |exists|
|
334
|
-
if exists
|
335
|
-
check[:output] = 'Keep-alive sent from host'
|
336
|
-
check[:status] = 0
|
337
|
-
end
|
338
|
-
end
|
339
|
-
end
|
340
|
-
unless check.empty?
|
341
|
-
check.merge(
|
329
|
+
unless @rabbitmq.reconnecting?
|
330
|
+
@logger.debug('checking for stale client info')
|
331
|
+
@redis.smembers('clients').callback do |clients|
|
332
|
+
clients.each do |client_name|
|
333
|
+
@redis.get('client:' + client_name).callback do |client_json|
|
334
|
+
client = JSON.parse(client_json, :symbolize_names => true)
|
335
|
+
check = {
|
342
336
|
:name => 'keepalive',
|
343
337
|
:issued => Time.now.to_i
|
344
|
-
)
|
345
|
-
payload = {
|
346
|
-
:client => client[:name],
|
347
|
-
:check => check
|
348
338
|
}
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
339
|
+
time_since_last_keepalive = Time.now.to_i - client[:timestamp]
|
340
|
+
case
|
341
|
+
when time_since_last_keepalive >= 180
|
342
|
+
check[:output] = 'No keep-alive sent from host in over 180 seconds'
|
343
|
+
check[:status] = 2
|
344
|
+
publish_result(client, check)
|
345
|
+
when time_since_last_keepalive >= 120
|
346
|
+
check[:output] = 'No keep-alive sent from host in over 120 seconds'
|
347
|
+
check[:status] = 1
|
348
|
+
publish_result(client, check)
|
349
|
+
else
|
350
|
+
@redis.hexists('events:' + client[:name], 'keepalive').callback do |exists|
|
351
|
+
if exists
|
352
|
+
check[:output] = 'Keep-alive sent from host'
|
353
|
+
check[:status] = 0
|
354
|
+
publish_result(client, check)
|
355
|
+
end
|
356
|
+
end
|
357
|
+
end
|
353
358
|
end
|
354
359
|
end
|
355
360
|
end
|
data/lib/sensu/settings.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 62196231
|
5
5
|
prerelease: true
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 9
|
9
9
|
- 6
|
10
10
|
- beta
|
11
|
-
-
|
12
|
-
version: 0.9.6.beta.
|
11
|
+
- 2
|
12
|
+
version: 0.9.6.beta.2
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- Sean Porter
|