sensu 0.9.5.beta → 0.9.5.beta.1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/sensu.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Sensu
2
- VERSION = "0.9.5.beta"
2
+ VERSION = "0.9.5.beta.1"
3
3
  end
data/lib/sensu/api.rb CHANGED
@@ -38,8 +38,8 @@ module Sensu
38
38
  $logger.debug('[setup] -- connecting to redis')
39
39
  $redis = Redis.connect($settings.redis.to_hash.symbolize_keys)
40
40
  $logger.debug('[setup] -- connecting to rabbitmq')
41
- rabbitmq = AMQP.connect($settings.rabbitmq.to_hash.symbolize_keys)
42
- $amq = AMQP::Channel.new(rabbitmq)
41
+ $rabbitmq = AMQP.connect($settings.rabbitmq.to_hash.symbolize_keys)
42
+ $amq = AMQP::Channel.new($rabbitmq)
43
43
  end
44
44
 
45
45
  before do
@@ -51,8 +51,18 @@ module Sensu
51
51
  response = {
52
52
  :sensu => {
53
53
  :version => Sensu::VERSION
54
+ },
55
+ :health => {
56
+ :redis => 'ok',
57
+ :rabbitmq => 'ok'
54
58
  }
55
59
  }
60
+ if $redis.reconnecting?
61
+ response[:health][:redis] = 'down'
62
+ end
63
+ if $rabbitmq.reconnecting?
64
+ response[:health][:rabbitmq] = 'down'
65
+ end
56
66
  body response.to_json
57
67
  end
58
68
 
@@ -2,6 +2,7 @@ module Redis
2
2
  class Client
3
3
  def connection_completed
4
4
  @connected = true
5
+ @reconnecting = false
5
6
  @port, @host = Socket.unpack_sockaddr_in(get_peername)
6
7
  end
7
8
 
@@ -13,6 +14,7 @@ module Redis
13
14
  def unbind
14
15
  unless !@connected || @closing_connection
15
16
  EM::Timer.new(1) do
17
+ @reconnecting = true
16
18
  reconnect(@host, @port)
17
19
  end
18
20
  else
@@ -24,6 +26,10 @@ module Redis
24
26
  end
25
27
  end
26
28
  end
29
+
30
+ def reconnecting?
31
+ @reconnecting || false
32
+ end
27
33
  end
28
34
 
29
35
  def self.connect(options={})
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31098141
4
+ hash: 62196249
5
5
  prerelease: true
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
9
  - 5
10
10
  - beta
11
- version: 0.9.5.beta
11
+ - 1
12
+ version: 0.9.5.beta.1
12
13
  platform: ruby
13
14
  authors:
14
15
  - Sean Porter