sensu 0.5.4 → 0.5.5

Sign up to get free protection for your applications and to get access to all the features.
data/lib/sensu/api.rb CHANGED
@@ -26,7 +26,7 @@ module Sensu
26
26
  @settings = config.settings
27
27
  set :redis, EM::Hiredis.connect('redis://' + @settings['redis']['host'] + ':' + @settings['redis']['port'].to_s)
28
28
  connection = AMQP.connect(symbolize_keys(@settings['rabbitmq']))
29
- set :amq, AMQP::Channel.new(connection)
29
+ set :amq, MQ.new(connection)
30
30
  end
31
31
 
32
32
  helpers do
data/lib/sensu/client.rb CHANGED
@@ -27,7 +27,7 @@ module Sensu
27
27
 
28
28
  def setup_amqp
29
29
  connection = AMQP.connect(symbolize_keys(@settings['rabbitmq']))
30
- @amq = AMQP::Channel.new(connection)
30
+ @amq = MQ.new(connection)
31
31
  @result_queue = @amq.queue('results')
32
32
  end
33
33
 
@@ -72,7 +72,7 @@ module Sensu
72
72
  def setup_subscriptions
73
73
  @settings['client']['subscriptions'].each do |exchange|
74
74
  uniq_queue_name = UUIDTools::UUID.random_create.to_s
75
- @amq.queue(uniq_queue_name, :auto_delete => true).bind(@amq.fanout(exchange)).subscribe do |check_json|
75
+ @amq.queue(uniq_queue_name, :exclusive => true).bind(@amq.fanout(exchange)).subscribe do |check_json|
76
76
  check = JSON.parse(check_json)
77
77
  execute_check(check)
78
78
  end
data/lib/sensu/server.rb CHANGED
@@ -45,7 +45,7 @@ module Sensu
45
45
 
46
46
  def setup_amqp
47
47
  connection = AMQP.connect(symbolize_keys(@settings['rabbitmq']))
48
- @amq = AMQP::Channel.new(connection)
48
+ @amq = MQ.new(connection)
49
49
  end
50
50
 
51
51
  def setup_keep_alives
@@ -101,29 +101,20 @@ module Sensu
101
101
  check = result['check']
102
102
  check.merge!(@settings['checks'][check['name']]) if @settings['checks'].has_key?(check['name'])
103
103
  check['handler'] = 'default' unless check['handler']
104
- event = {
105
- 'client' => client,
106
- 'check' => check
107
- }
104
+ event = {'client' => client, 'check' => check}
108
105
  if check['type'] == 'metric'
109
106
  handle_event(event)
110
107
  else
111
- if check['status'] == 0
112
- @redis.hexists('events:' + client['name'], check['name']).callback do |exists|
113
- if exists == 1
114
- @redis.hdel('events:' + client['name'], check['name'])
115
- event['action'] = 'resolve'
116
- handle_event(event)
117
- end
118
- end
119
- else
120
- @redis.hget('events:' + client['name'], check['name']).callback do |event_json|
108
+ @redis.hget('events:' + client['name'], check['name']).callback do |event_json|
109
+ previous_event = event_json ? JSON.parse(event_json) : nil
110
+ if previous_event && check['status'] == 0
111
+ @redis.hdel('events:' + client['name'], check['name'])
112
+ event['action'] = 'resolve'
113
+ handle_event(event)
114
+ else
121
115
  occurrences = 1
122
- unless event_json.nil?
123
- previous_event = JSON.parse(event_json)
124
- if previous_event['status'] == check['status']
125
- occurrences = previous_event['occurrences'] += 1
126
- end
116
+ if previous_event && check['status'] == previous_event['status']
117
+ occurrences = previous_event['occurrences'] += 1
127
118
  end
128
119
  @redis.hset('events:' + client['name'], check['name'], {'status' => check['status'], 'output' => check['output'], 'occurrences' => occurrences}.to_json).callback do
129
120
  event['occurrences'] = occurrences
data/sensu.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "sensu"
3
- s.version = "0.5.4"
3
+ s.version = "0.5.5"
4
4
  s.authors = ["Sean Porter", "Justin Kolberg"]
5
5
  s.email = ["sean.porter@sonian.net", "justin.kolberg@sonian.net"]
6
6
  s.homepage = "https://github.com/sonian/sensu"
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: sensu
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.5.4
5
+ version: 0.5.5
6
6
  platform: ruby
7
7
  authors:
8
8
  - Sean Porter