sensu 0.9.9.beta.4 → 0.9.9

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
- ## 0.9.9 - TBD
1
+ ## 0.9.9 - 2013-01-14
2
2
 
3
3
  ### Features
4
4
 
@@ -1,6 +1,6 @@
1
1
  module Sensu
2
2
  unless defined?(Sensu::VERSION)
3
- VERSION = '0.9.9.beta.4'
3
+ VERSION = '0.9.9'
4
4
 
5
5
  DEFAULT_OPTIONS = {
6
6
  :config_file => '/etc/sensu/config.json',
data/lib/sensu/io.rb CHANGED
@@ -9,7 +9,7 @@ module Sensu
9
9
  if RUBY_VERSION < '1.9.3'
10
10
  child = ::IO.popen(command + ' 2>&1', mode)
11
11
  block.call(child)
12
- wait_on_process(child)
12
+ wait_on_process(child, false)
13
13
  else
14
14
  options = {
15
15
  :err => [:child, :out]
@@ -34,22 +34,36 @@ module Sensu
34
34
  end
35
35
  end
36
36
  rescue Timeout::Error
37
- begin
38
- ::Process.kill(9, -child.pid)
39
- loop do
40
- ::Process.wait2(-child.pid)
41
- end
42
- rescue Errno::ESRCH, Errno::ECHILD
43
- ['Execution timed out', 2]
44
- end
37
+ kill_process_group(child.pid)
38
+ wait_on_process_group(child.pid)
39
+ ['Execution timed out', 2]
45
40
  end
46
41
  end
47
42
 
48
43
  private
49
44
 
50
- def wait_on_process(process)
45
+ def kill_process_group(group_id)
46
+ begin
47
+ ::Process.kill(9, -group_id)
48
+ rescue Errno::ESRCH, Errno::EPERM
49
+ end
50
+ end
51
+
52
+ def wait_on_process_group(group_id)
53
+ begin
54
+ loop do
55
+ ::Process.wait2(-group_id)
56
+ end
57
+ rescue Errno::ECHILD
58
+ end
59
+ end
60
+
61
+ def wait_on_process(process, wait_on_group=true)
51
62
  output = process.read
52
63
  _, status = ::Process.wait2(process.pid)
64
+ if wait_on_group
65
+ wait_on_process_group(process.pid)
66
+ end
53
67
  [output, status.exitstatus]
54
68
  end
55
69
  end
data/lib/sensu/server.rb CHANGED
@@ -69,6 +69,7 @@ module Sensu
69
69
  end
70
70
  @rabbitmq.after_reconnect do
71
71
  @logger.info('reconnected to rabbitmq')
72
+ @amq.prefetch(1)
72
73
  end
73
74
  @amq = @rabbitmq.channel
74
75
  @amq.prefetch(1)
@@ -76,7 +77,10 @@ module Sensu
76
77
 
77
78
  def setup_keepalives
78
79
  @logger.debug('subscribing to keepalives')
79
- @keepalive_queue = @amq.queue('keepalives')
80
+ @amq.queue('keepalives').consumers.each do |consumer_tag, consumer|
81
+ consumer.cancel
82
+ end
83
+ @keepalive_queue = @amq.queue!('keepalives')
80
84
  @keepalive_queue.subscribe(:ack => true) do |header, payload|
81
85
  client = JSON.parse(payload, :symbolize_names => true)
82
86
  @logger.debug('received keepalive', {
@@ -129,7 +133,7 @@ module Sensu
129
133
  true
130
134
  when hash_one[key].is_a?(Hash) && hash_two[key].is_a?(Hash)
131
135
  filter_attributes_match?(hash_one[key], hash_two[key])
132
- when hash_one[key].is_a?(String) && hash_one[key].start_with?('eval: ')
136
+ when hash_one[key].is_a?(String) && hash_one[key].start_with?('eval:')
133
137
  begin
134
138
  expression = hash_one[key].gsub(/^eval:(\s+)?/, '')
135
139
  !!Sandbox.eval(expression, hash_two[key])
@@ -220,7 +224,7 @@ module Sensu
220
224
  event_filtered?(filter_name, event)
221
225
  end
222
226
  if filtered
223
- @logger.debug('event filtered for handler', {
227
+ @logger.info('event filtered for handler', {
224
228
  :event => event,
225
229
  :handler => handler
226
230
  })
@@ -490,7 +494,10 @@ module Sensu
490
494
 
491
495
  def setup_results
492
496
  @logger.debug('subscribing to results')
493
- @result_queue = @amq.queue('results')
497
+ @amq.queue('results').consumers.each do |consumer_tag, consumer|
498
+ consumer.cancel
499
+ end
500
+ @result_queue = @amq.queue!('results')
494
501
  @result_queue.subscribe(:ack => true) do |header, payload|
495
502
  result = JSON.parse(payload, :symbolize_names => true)
496
503
  @logger.debug('received result', {
@@ -703,6 +710,7 @@ module Sensu
703
710
  @keepalive_queue.unsubscribe
704
711
  @result_queue.unsubscribe
705
712
  if @rabbitmq.connected?
713
+ @amq.recover
706
714
  timestamp = Time.now.to_i
707
715
  retry_until_true do
708
716
  if !@keepalive_queue.subscribed? && !@result_queue.subscribed?
metadata CHANGED
@@ -1,15 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1725596175
5
- prerelease: true
4
+ hash: 41
5
+ prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
9
  - 9
10
- - beta
11
- - 4
12
- version: 0.9.9.beta.4
10
+ version: 0.9.9
13
11
  platform: ruby
14
12
  authors:
15
13
  - Sean Porter
@@ -18,7 +16,7 @@ autorequire:
18
16
  bindir: bin
19
17
  cert_chain: []
20
18
 
21
- date: 2013-01-13 00:00:00 -08:00
19
+ date: 2013-01-14 00:00:00 -08:00
22
20
  default_executable:
23
21
  dependencies:
24
22
  - !ruby/object:Gem::Dependency
@@ -233,14 +231,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
233
231
  required_rubygems_version: !ruby/object:Gem::Requirement
234
232
  none: false
235
233
  requirements:
236
- - - ">"
234
+ - - ">="
237
235
  - !ruby/object:Gem::Version
238
- hash: 25
236
+ hash: 3
239
237
  segments:
240
- - 1
241
- - 3
242
- - 1
243
- version: 1.3.1
238
+ - 0
239
+ version: "0"
244
240
  requirements: []
245
241
 
246
242
  rubyforge_project: