sensu 0.5.5 → 0.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
- uniq_queue_name = UUIDTools::UUID.random_create.to_s
75
- @amq.queue(uniq_queue_name, :exclusive => true).bind(@amq.fanout(exchange)).subscribe do |check_json|
76
- check = JSON.parse(check_json)
77
- execute_check(check)
78
- end
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
- @amq.queue('checks').subscribe do |check_json|
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(7*index) do
150
- EM.add_periodic_timer(details['interval']) do
151
- check_queue.publish({'name' => name, 'subscribers' => details['subscribers']}.to_json)
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
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "sensu"
3
- s.version = "0.5.5"
3
+ s.version = "0.5.6"
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.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-16 00:00:00 Z
14
+ date: 2011-09-18 00:00:00 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: amqp