sensu 0.5.5 → 0.5.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/sensu/client.rb +7 -6
- data/lib/sensu/server.rb +12 -19
- data/sensu.gemspec +1 -1
- metadata +2 -2
data/lib/sensu/client.rb
CHANGED
@@ -40,10 +40,10 @@ module Sensu
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def execute_check(check)
|
43
|
+
result = {'client' => @settings['client']['name'], 'check' => check}
|
43
44
|
if @settings['checks'].has_key?(check['name'])
|
44
45
|
unless @checks_in_progress.include?(check['name'])
|
45
46
|
@checks_in_progress.push(check['name'])
|
46
|
-
result = {'client' => @settings['client']['name'], 'check' => check}
|
47
47
|
unmatched_tokens = Array.new
|
48
48
|
command = @settings['checks'][check['name']]['command'].gsub(/:::(.*?):::/) do
|
49
49
|
key = $1.to_s
|
@@ -70,12 +70,13 @@ module Sensu
|
|
70
70
|
end
|
71
71
|
|
72
72
|
def setup_subscriptions
|
73
|
+
uniq_queue = @amq.queue(UUIDTools::UUID.random_create.to_s, :exclusive => true)
|
73
74
|
@settings['client']['subscriptions'].each do |exchange|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
75
|
+
uniq_queue.bind(@amq.fanout(exchange))
|
76
|
+
end
|
77
|
+
uniq_queue.subscribe do |check_json|
|
78
|
+
check = JSON.parse(check_json)
|
79
|
+
execute_check(check)
|
79
80
|
end
|
80
81
|
end
|
81
82
|
end
|
data/lib/sensu/server.rb
CHANGED
@@ -16,7 +16,6 @@ module Sensu
|
|
16
16
|
server.setup_handlers
|
17
17
|
server.setup_results
|
18
18
|
server.setup_publisher
|
19
|
-
server.setup_populator
|
20
19
|
server.setup_keep_alive_monitor
|
21
20
|
|
22
21
|
Signal.trap('INT') do
|
@@ -129,26 +128,20 @@ module Sensu
|
|
129
128
|
end
|
130
129
|
end
|
131
130
|
|
132
|
-
def setup_publisher
|
131
|
+
def setup_publisher(options={})
|
133
132
|
exchanges = Hash.new
|
134
|
-
|
135
|
-
check = JSON.parse(check_json)
|
136
|
-
check['subscribers'].each do |exchange|
|
137
|
-
if exchanges[exchange].nil?
|
138
|
-
exchanges[exchange] = @amq.fanout(exchange)
|
139
|
-
end
|
140
|
-
exchanges[exchange].publish({'name' => check['name'], 'issued' => Time.now.to_i}.to_json)
|
141
|
-
EM.debug('published :: ' + exchange + ' :: ' + check['name'])
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
def setup_populator
|
147
|
-
check_queue = @amq.queue('checks')
|
133
|
+
stagger = options[:test] ? 0 : 7
|
148
134
|
@settings['checks'].each_with_index do |(name, details), index|
|
149
|
-
EM.add_timer(
|
150
|
-
|
151
|
-
|
135
|
+
EM.add_timer(stagger*index) do
|
136
|
+
details['subscribers'].each do |exchange|
|
137
|
+
if exchanges[exchange].nil?
|
138
|
+
exchanges[exchange] = @amq.fanout(exchange)
|
139
|
+
end
|
140
|
+
interval = options[:test] ? 0.5 : details['interval']
|
141
|
+
EM.add_periodic_timer(interval) do
|
142
|
+
exchanges[exchange].publish({'name' => name, 'issued' => Time.now.to_i}.to_json)
|
143
|
+
EM.debug('published :: ' + exchange + ' :: ' + name)
|
144
|
+
end
|
152
145
|
end
|
153
146
|
end
|
154
147
|
end
|
data/sensu.gemspec
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: sensu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.5.
|
5
|
+
version: 0.5.6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Sean Porter
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2011-09-
|
14
|
+
date: 2011-09-18 00:00:00 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: amqp
|