sensu 0.11.0.beta.4 → 0.11.0

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/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
- ## 0.11.0 - TBD
1
+ ## 0.11.0 - 2013-10-02
2
2
 
3
3
  ### Non-backwards compatible changes
4
4
 
@@ -26,6 +26,9 @@ You can configure the Sensu client socket (UDP & TCP), bind & port, eg.
26
26
 
27
27
  Handlers & mutators can now have a timeout, in seconds.
28
28
 
29
+ You can configure the RabbitMQ channel prefetch value (advanced), eg.
30
+ "rabbitmq": { "prefetch": 100 }.
31
+
29
32
  ### Other
30
33
 
31
34
  Sensu passes a dup of event data to mutator & handler extensions to
data/lib/sensu/api.rb CHANGED
@@ -356,15 +356,16 @@ module Sensu
356
356
  $logger.info('deleting client', {
357
357
  :client => client
358
358
  })
359
- $redis.srem('clients', client_name)
360
- $redis.del('events:' + client_name)
361
- $redis.del('client:' + client_name)
362
- $redis.smembers('history:' + client_name) do |checks|
363
- checks.each do |check_name|
364
- $redis.del('history:' + client_name + ':' + check_name)
365
- $redis.del('execution:' + client_name + ':' + check_name)
359
+ $redis.srem('clients', client_name) do
360
+ $redis.del('client:' + client_name)
361
+ $redis.del('events:' + client_name)
362
+ $redis.smembers('history:' + client_name) do |checks|
363
+ checks.each do |check_name|
364
+ $redis.del('history:' + client_name + ':' + check_name)
365
+ $redis.del('execution:' + client_name + ':' + check_name)
366
+ end
367
+ $redis.del('history:' + client_name)
366
368
  end
367
- $redis.del('history:' + client_name)
368
369
  end
369
370
  end
370
371
  issued!
@@ -1,6 +1,6 @@
1
1
  module Sensu
2
2
  unless defined?(Sensu::VERSION)
3
- VERSION = '0.11.0.beta.4'
3
+ VERSION = '0.11.0'
4
4
 
5
5
  LOG_LEVELS = [:debug, :info, :warn, :error, :fatal]
6
6
 
@@ -81,7 +81,7 @@ module Sensu
81
81
  extension
82
82
  end
83
83
  end
84
- all.flatten!
84
+ all.flatten
85
85
  end
86
86
 
87
87
  def loaded(type, name, description)
@@ -77,9 +77,15 @@ module Sensu
77
77
  error = RabbitMQError.new('rabbitmq channel closed')
78
78
  @on_error.call(error)
79
79
  end
80
+ prefetch = 1
81
+ if options.is_a?(Hash)
82
+ prefetch = options[:prefetch] || 1
83
+ end
80
84
  @channel.on_recovery do
81
85
  @after_reconnect.call
86
+ @channel.prefetch(prefetch)
82
87
  end
88
+ @channel.prefetch(prefetch)
83
89
  end
84
90
 
85
91
  def connected?
data/lib/sensu/server.rb CHANGED
@@ -72,11 +72,9 @@ module Sensu
72
72
  end
73
73
  @rabbitmq.after_reconnect do
74
74
  @logger.info('reconnected to rabbitmq')
75
- @amq.prefetch(1)
76
75
  resume
77
76
  end
78
77
  @amq = @rabbitmq.channel
79
- @amq.prefetch(1)
80
78
  end
81
79
 
82
80
  def setup_keepalives(&block)
@@ -571,35 +569,30 @@ module Sensu
571
569
  unless client_json.nil?
572
570
  client = Oj.load(client_json)
573
571
  check = {
574
- :name => 'keepalive',
575
- :issued => Time.now.to_i,
576
- :executed => Time.now.to_i
577
- }
578
- thresholds = {
579
- :warning => 120,
580
- :critical => 180
572
+ :thresholds => {
573
+ :warning => 120,
574
+ :critical => 180
575
+ }
581
576
  }
582
577
  if client.has_key?(:keepalive)
583
- if client[:keepalive].has_key?(:handler) || client[:keepalive].has_key?(:handlers)
584
- check[:handlers] = Array(client[:keepalive][:handlers] || client[:keepalive][:handler])
585
- end
586
- if client[:keepalive].has_key?(:thresholds)
587
- thresholds.merge!(client[:keepalive][:thresholds])
588
- end
578
+ check = deep_merge(check, client[:keepalive])
589
579
  end
580
+ check[:name] = 'keepalive'
581
+ check[:issued] = Time.now.to_i
582
+ check[:executed] = Time.now.to_i
590
583
  time_since_last_keepalive = Time.now.to_i - client[:timestamp]
591
584
  case
592
- when time_since_last_keepalive >= thresholds[:critical]
585
+ when time_since_last_keepalive >= check[:thresholds][:critical]
593
586
  check[:output] = 'No keep-alive sent from client in over '
594
- check[:output] << thresholds[:critical].to_s + ' seconds'
587
+ check[:output] << check[:thresholds][:critical].to_s + ' seconds'
595
588
  check[:status] = 2
596
- when time_since_last_keepalive >= thresholds[:warning]
589
+ when time_since_last_keepalive >= check[:thresholds][:warning]
597
590
  check[:output] = 'No keep-alive sent from client in over '
598
- check[:output] << thresholds[:warning].to_s + ' seconds'
591
+ check[:output] << check[:thresholds][:warning].to_s + ' seconds'
599
592
  check[:status] = 1
600
593
  else
601
594
  check[:output] = 'Keep-alive sent from client less than '
602
- check[:output] << thresholds[:warning].to_s + ' seconds ago'
595
+ check[:output] << check[:thresholds][:warning].to_s + ' seconds ago'
603
596
  check[:status] = 0
604
597
  end
605
598
  publish_result(client, check)
@@ -439,10 +439,12 @@ module Sensu
439
439
  unless thresholds.is_a?(Hash)
440
440
  invalid('client keepalive thresholds must be a hash')
441
441
  end
442
- if thresholds.has_key?(:warning) || thresholds.has_key?(:critical)
442
+ if thresholds.has_key?(:warning)
443
443
  unless thresholds[:warning].is_a?(Integer)
444
444
  invalid('client keepalive warning threshold must be an integer')
445
445
  end
446
+ end
447
+ if thresholds.has_key?(:critical)
446
448
  unless thresholds[:critical].is_a?(Integer)
447
449
  invalid('client keepalive critical threshold must be an integer')
448
450
  end
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: 346800981
5
- prerelease: true
4
+ hash: 51
5
+ prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 11
9
9
  - 0
10
- - beta
11
- - 4
12
- version: 0.11.0.beta.4
10
+ version: 0.11.0
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-09-30 00:00:00 -07:00
19
+ date: 2013-10-02 00:00:00 -07:00
22
20
  default_executable:
23
21
  dependencies:
24
22
  - !ruby/object:Gem::Dependency
@@ -235,14 +233,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
235
233
  required_rubygems_version: !ruby/object:Gem::Requirement
236
234
  none: false
237
235
  requirements:
238
- - - ">"
236
+ - - ">="
239
237
  - !ruby/object:Gem::Version
240
- hash: 25
238
+ hash: 3
241
239
  segments:
242
- - 1
243
- - 3
244
- - 1
245
- version: 1.3.1
240
+ - 0
241
+ version: "0"
246
242
  requirements: []
247
243
 
248
244
  rubyforge_project: