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 +1 -1
- data/lib/sensu/client.rb +2 -2
- data/lib/sensu/server.rb +11 -20
- data/sensu.gemspec +1 -1
- metadata +1 -1
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,
|
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 =
|
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, :
|
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 =
|
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
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
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
|
-
|
123
|
-
|
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