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 CHANGED
@@ -48,6 +48,7 @@ module Sensu
48
48
  @logger.fatal('SENSU NOT RUNNING!')
49
49
  exit 2
50
50
  end
51
+ @settings.set_env
51
52
  end
52
53
 
53
54
  def setup_process
@@ -1,5 +1,5 @@
1
1
  module Sensu
2
- VERSION = '0.9.6.beta.1'
2
+ VERSION = '0.9.6.beta.2'
3
3
 
4
4
  DEFAULT_OPTIONS = {
5
5
  :config_file => '/etc/sensu/config.json',
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
- @logger.debug('checking for stale client info')
319
- @redis.smembers('clients').callback do |clients|
320
- clients.each do |client_name|
321
- @redis.get('client:' + client_name).callback do |client_json|
322
- client = JSON.parse(client_json, :symbolize_names => true)
323
- time_since_last_keepalive = Time.now.to_i - client[:timestamp]
324
- check = Hash.new
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
- @logger.info('publishing check result', {
350
- :payload => payload
351
- })
352
- @amq.queue('results').publish(payload.to_json)
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
@@ -82,6 +82,10 @@ module Sensu
82
82
  end
83
83
  end
84
84
 
85
+ def set_env
86
+ ENV['SENSU_CONFIG_FILES'] = @loaded_files.join(':')
87
+ end
88
+
85
89
  def checks
86
90
  @settings[:checks].map do |check_name, check_details|
87
91
  check_details.merge(:name => check_name.to_s)
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: 62196225
4
+ hash: 62196231
5
5
  prerelease: true
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
9
  - 6
10
10
  - beta
11
- - 1
12
- version: 0.9.6.beta.1
11
+ - 2
12
+ version: 0.9.6.beta.2
13
13
  platform: ruby
14
14
  authors:
15
15
  - Sean Porter