sensu 0.8.7 → 0.8.9

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,20 +1,22 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sensu (0.8.5)
4
+ sensu (0.8.9)
5
5
  amqp (= 0.7.4)
6
6
  async_sinatra
7
7
  cabin (= 0.1.7)
8
- em-hiredis
8
+ eventmachine (~> 1.0.0.beta.4)
9
9
  hashie
10
10
  json
11
11
  rack (~> 1.3.4)
12
+ ruby-redis
12
13
  thin
13
14
  uuidtools
14
15
 
15
16
  GEM
16
17
  remote: http://rubygems.org/
17
18
  specs:
19
+ addressable (2.2.6)
18
20
  amqp (0.7.4)
19
21
  eventmachine
20
22
  async_sinatra (0.5.0)
@@ -25,21 +27,23 @@ GEM
25
27
  json
26
28
  daemons (1.1.4)
27
29
  diff-lcs (1.1.3)
28
- em-hiredis (0.1.0)
29
- hiredis (~> 0.3.0)
30
+ em-http-request (0.3.0)
31
+ addressable (>= 2.0.0)
32
+ escape_utils
33
+ eventmachine (>= 0.12.9)
30
34
  em-spec (0.2.5)
31
35
  bacon
32
36
  eventmachine
33
37
  rspec (~> 2.6.0)
34
38
  test-unit
35
- eventmachine (0.12.10)
39
+ escape_utils (0.2.4)
40
+ eventmachine (1.0.0.beta.4)
36
41
  hashie (1.2.0)
37
- hiredis (0.3.2)
38
42
  json (1.6.1)
39
43
  rack (1.3.5)
40
44
  rack-protection (1.1.4)
41
45
  rack
42
- rake (0.9.2)
46
+ rake (0.9.2.2)
43
47
  rspec (2.6.0)
44
48
  rspec-core (~> 2.6.0)
45
49
  rspec-expectations (~> 2.6.0)
@@ -48,12 +52,14 @@ GEM
48
52
  rspec-expectations (2.6.0)
49
53
  diff-lcs (~> 1.1.2)
50
54
  rspec-mocks (2.6.0)
55
+ ruby-redis (0.0.2)
56
+ eventmachine
51
57
  sinatra (1.3.1)
52
58
  rack (~> 1.3, >= 1.3.4)
53
59
  rack-protection (~> 1.1, >= 1.1.2)
54
60
  tilt (~> 1.3, >= 1.3.3)
55
- test-unit (2.4.0)
56
- thin (1.2.11)
61
+ test-unit (2.4.1)
62
+ thin (1.3.1)
57
63
  daemons (>= 1.0.9)
58
64
  eventmachine (>= 0.12.6)
59
65
  rack (>= 1.0.0)
@@ -64,6 +70,7 @@ PLATFORMS
64
70
  ruby
65
71
 
66
72
  DEPENDENCIES
73
+ em-http-request
67
74
  em-spec
68
75
  rake
69
76
  sensu!
data/Rakefile CHANGED
@@ -9,9 +9,3 @@ task :test do
9
9
  require File.join(File.dirname(__FILE__), test)
10
10
  end
11
11
  end
12
-
13
- desc "Build Sensu for Windows"
14
- task :build_windows do
15
- puts `sh -c 'BUILD=mswin gem build sensu.windows'`
16
- puts `sh -c 'BUILD=mingw gem build sensu.windows'`
17
- end
data/bin/sensu-api CHANGED
@@ -1,7 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- raise "The Sensu API does not run on Windows" if RUBY_PLATFORM.downcase =~ /mswin|mingw32|windows/
4
-
5
3
  $: << File.dirname(__FILE__) + '/../lib' unless $:.include?(File.dirname(__FILE__) + '/../lib/')
6
4
  require 'sensu/api'
7
5
 
data/bin/sensu-server CHANGED
@@ -1,7 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- raise "The Sensu Server does not run on Windows" if RUBY_PLATFORM.downcase =~ /mswin|mingw32|windows/
4
-
5
3
  $: << File.dirname(__FILE__) + '/../lib' unless $:.include?(File.dirname(__FILE__) + '/../lib/')
6
4
  require 'sensu/server'
7
5
 
data/lib/sensu.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Sensu
2
- VERSION = "0.8.7"
2
+ VERSION = "0.8.9"
3
3
  end
data/lib/sensu/api.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require File.join(File.dirname(__FILE__), 'config')
2
2
  require 'sinatra/async'
3
- require 'em-hiredis'
3
+ require 'redis'
4
4
 
5
5
  module Sensu
6
6
  class API < Sinatra::Base
@@ -24,7 +24,7 @@ module Sensu
24
24
  @settings = config.settings
25
25
  $logger = config.logger
26
26
  $logger.debug('[setup] -- connecting to redis')
27
- $redis = EM::Hiredis.connect('redis://' + @settings.redis.host + ':' + @settings.redis.port.to_s)
27
+ $redis = EM.connect(@settings.redis.host, @settings.redis.port, Redis::Client)
28
28
  $logger.debug('[setup] -- connecting to rabbitmq')
29
29
  connection = AMQP.connect(@settings.rabbitmq.to_hash.symbolize_keys)
30
30
  $amq = MQ.new(connection)
@@ -69,21 +69,13 @@ module Sensu
69
69
  adelete '/client/:name' do |client|
70
70
  $logger.debug('[client] -- ' + request.ip + ' -- DELETE -- request for client -- ' + client)
71
71
  $redis.sismember('clients', client).callback do |client_exists|
72
- unless client_exists == 0
73
- $redis.exists('events:' + client).callback do |events_exist|
74
- unless events_exist == 0
75
- $redis.hgetall('events:' + client).callback do |events|
76
- Hash[*events].keys.each do |check_name|
77
- check = {:name => check_name, :issued => Time.now.to_i, :status => 0, :output => 'Client is being removed'}
78
- $amq.queue('results').publish({:client => client, :check => check}.to_json)
79
- end
80
- EM.add_timer(5) do
81
- $redis.srem('clients', client)
82
- $redis.del('events:' + client)
83
- $redis.del('client:' + client)
84
- end
85
- end
86
- else
72
+ if client_exists
73
+ $redis.hgetall('events:' + client).callback do |events|
74
+ events.keys.each do |check_name|
75
+ check = {:name => check_name, :issued => Time.now.to_i, :status => 0, :output => 'Client is being removed'}
76
+ $amq.queue('results').publish({:client => client, :check => check}.to_json)
77
+ end
78
+ EM.add_timer(5) do
87
79
  $redis.srem('clients', client)
88
80
  $redis.del('events:' + client)
89
81
  $redis.del('client:' + client)
@@ -105,7 +97,7 @@ module Sensu
105
97
  unless clients.empty?
106
98
  clients.each_with_index do |client, index|
107
99
  $redis.hgetall('events:' + client).callback do |events|
108
- client_events = Hash[*events]
100
+ client_events = events
109
101
  client_events.each do |key, value|
110
102
  client_events[key] = JSON.parse(value)
111
103
  end
@@ -122,7 +114,7 @@ module Sensu
122
114
  aget '/event/:client/:check' do |client, check|
123
115
  $logger.debug('[event] -- ' + request.ip + ' -- GET -- request for event -- ' + client + ' -- ' + check)
124
116
  $redis.hgetall('events:' + client).callback do |events|
125
- client_events = Hash[*events]
117
+ client_events = events
126
118
  event = client_events[check]
127
119
  status 404 if event.nil?
128
120
  body event
@@ -139,7 +131,7 @@ module Sensu
139
131
  end
140
132
  if event.has_key?('client') && event.has_key?('check')
141
133
  $redis.hgetall('events:' + event['client']).callback do |events|
142
- if Hash[*events][event['check']]
134
+ if events.has_key?(event['check'])
143
135
  check = {:name => event['check'], :issued => Time.now.to_i, :status => 0, :output => 'Resolving on request of the API'}
144
136
  $amq.queue('results').publish({:client => event['client'], :check => check}.to_json)
145
137
  status 201
@@ -177,7 +169,7 @@ module Sensu
177
169
  body nil
178
170
  end
179
171
  stashes = Hash.new
180
- if paths.is_a?(Array)
172
+ if paths.is_a?(Array) && paths.size > 0
181
173
  paths.each_with_index do |path, index|
182
174
  $redis.get('stash:' + path).callback do |stash|
183
175
  stashes[path] = JSON.parse(stash) unless stash.nil?
@@ -201,7 +193,7 @@ module Sensu
201
193
  adelete '/stash/*' do |path|
202
194
  $logger.debug('[stash] -- ' + request.ip + ' -- DELETE -- request for stash -- ' + path)
203
195
  $redis.exists('stash:' + path).callback do |stash_exist|
204
- unless stash_exist == 0
196
+ if stash_exist
205
197
  $redis.del('stash:' + path).callback do
206
198
  status 204
207
199
  body nil
@@ -215,7 +207,7 @@ module Sensu
215
207
 
216
208
  def self.test(options={})
217
209
  self.setup(options)
218
- $redis.set('client:test', @settings.client).callback do
210
+ $redis.set('client:' + @settings.client.name, @settings.client.to_json).callback do
219
211
  $redis.sadd('clients', @settings.client.name).callback do
220
212
  $redis.hset('events:' + @settings.client.name, 'test', {
221
213
  :status => 2,
@@ -223,11 +215,12 @@ module Sensu
223
215
  :flapping => false,
224
216
  :occurrences => 1
225
217
  }.to_json).callback do
226
- $redis.set('stash:test/test', '{"key": "value"}')
218
+ $redis.set('stash:test/test', '{"key": "value"}').callback do
219
+ self.run!(:port => @settings.api.port)
220
+ end
227
221
  end
228
222
  end
229
223
  end
230
- self.run!(:port => @settings.api.port)
231
224
  end
232
225
  end
233
226
  end
data/lib/sensu/config.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'rubygems' if RUBY_VERSION < '1.9.0'
2
+ gem 'eventmachine', '~> 1.0.0.beta.4'
2
3
  require 'optparse'
3
4
  require 'json'
4
5
  require 'hashie'
data/lib/sensu/server.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require File.join(File.dirname(__FILE__), 'config')
2
- require 'em-hiredis'
2
+ require 'redis'
3
3
 
4
4
  module Sensu
5
5
  class Server
@@ -43,7 +43,7 @@ module Sensu
43
43
 
44
44
  def setup_redis
45
45
  @logger.debug('[redis] -- connecting to redis')
46
- @redis = EM::Hiredis.connect('redis://' + @settings.redis.host + ':' + @settings.redis.port.to_s)
46
+ @redis = EM.connect(@settings.redis.host, @settings.redis.port, Redis::Client)
47
47
  end
48
48
 
49
49
  def setup_amqp
@@ -229,7 +229,7 @@ module Sensu
229
229
  @result_queue.publish(result.to_json)
230
230
  else
231
231
  @redis.hexists('events:' + client_id, 'keepalive').callback do |exists|
232
- if exists == 1
232
+ if exists
233
233
  result.check.status = 0
234
234
  result.check.output = 'Keep-alive sent from host'
235
235
  @result_queue.publish(result.to_json)
data/sensu.gemspec CHANGED
@@ -7,23 +7,25 @@ Gem::Specification.new do |s|
7
7
  s.authors = ["Sean Porter", "Justin Kolberg"]
8
8
  s.email = ["sean.porter@sonian.net", "justin.kolberg@sonian.net"]
9
9
  s.homepage = "https://github.com/sonian/sensu"
10
- s.summary = %q{A monitoring framework}
11
- s.description = %q{A monitoring framework that aims to be simple, malleable, and scalable. Uses the publish/subscribe model.}
10
+ s.summary = "A monitoring framework"
11
+ s.description = "A monitoring framework that aims to be simple, malleable, and scalable. Uses the publish/subscribe model."
12
12
  s.license = "MIT"
13
13
  s.has_rdoc = false
14
14
 
15
+ s.add_dependency("eventmachine", "~> 1.0.0.beta.4")
15
16
  s.add_dependency("amqp", "0.7.4")
16
17
  s.add_dependency("json")
17
18
  s.add_dependency("hashie")
18
19
  s.add_dependency("uuidtools")
19
20
  s.add_dependency("cabin", "0.1.7")
20
- s.add_dependency("em-hiredis")
21
+ s.add_dependency("ruby-redis")
21
22
  s.add_dependency("rack", "~> 1.3.4")
22
23
  s.add_dependency("async_sinatra")
23
24
  s.add_dependency("thin")
24
25
 
25
26
  s.add_development_dependency("rake")
26
27
  s.add_development_dependency("em-spec")
28
+ s.add_development_dependency("em-http-request")
27
29
 
28
30
  s.files = `git ls-files`.split("\n").reject {|f| f =~ /(dist|test|png)/}
29
31
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu
3
3
  version: !ruby/object:Gem::Version
4
- hash: 49
4
+ hash: 45
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 8
9
- - 7
10
- version: 0.8.7
9
+ - 9
10
+ version: 0.8.9
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sean Porter
@@ -16,13 +16,31 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-11-14 00:00:00 -08:00
19
+ date: 2011-11-16 00:00:00 -08:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
- name: amqp
23
+ name: eventmachine
24
24
  prerelease: false
25
25
  requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ~>
29
+ - !ruby/object:Gem::Version
30
+ hash: 62196363
31
+ segments:
32
+ - 1
33
+ - 0
34
+ - 0
35
+ - beta
36
+ - 4
37
+ version: 1.0.0.beta.4
38
+ type: :runtime
39
+ version_requirements: *id001
40
+ - !ruby/object:Gem::Dependency
41
+ name: amqp
42
+ prerelease: false
43
+ requirement: &id002 !ruby/object:Gem::Requirement
26
44
  none: false
27
45
  requirements:
28
46
  - - "="
@@ -34,11 +52,11 @@ dependencies:
34
52
  - 4
35
53
  version: 0.7.4
36
54
  type: :runtime
37
- version_requirements: *id001
55
+ version_requirements: *id002
38
56
  - !ruby/object:Gem::Dependency
39
57
  name: json
40
58
  prerelease: false
41
- requirement: &id002 !ruby/object:Gem::Requirement
59
+ requirement: &id003 !ruby/object:Gem::Requirement
42
60
  none: false
43
61
  requirements:
44
62
  - - ">="
@@ -48,11 +66,11 @@ dependencies:
48
66
  - 0
49
67
  version: "0"
50
68
  type: :runtime
51
- version_requirements: *id002
69
+ version_requirements: *id003
52
70
  - !ruby/object:Gem::Dependency
53
71
  name: hashie
54
72
  prerelease: false
55
- requirement: &id003 !ruby/object:Gem::Requirement
73
+ requirement: &id004 !ruby/object:Gem::Requirement
56
74
  none: false
57
75
  requirements:
58
76
  - - ">="
@@ -62,11 +80,11 @@ dependencies:
62
80
  - 0
63
81
  version: "0"
64
82
  type: :runtime
65
- version_requirements: *id003
83
+ version_requirements: *id004
66
84
  - !ruby/object:Gem::Dependency
67
85
  name: uuidtools
68
86
  prerelease: false
69
- requirement: &id004 !ruby/object:Gem::Requirement
87
+ requirement: &id005 !ruby/object:Gem::Requirement
70
88
  none: false
71
89
  requirements:
72
90
  - - ">="
@@ -76,11 +94,11 @@ dependencies:
76
94
  - 0
77
95
  version: "0"
78
96
  type: :runtime
79
- version_requirements: *id004
97
+ version_requirements: *id005
80
98
  - !ruby/object:Gem::Dependency
81
99
  name: cabin
82
100
  prerelease: false
83
- requirement: &id005 !ruby/object:Gem::Requirement
101
+ requirement: &id006 !ruby/object:Gem::Requirement
84
102
  none: false
85
103
  requirements:
86
104
  - - "="
@@ -92,11 +110,11 @@ dependencies:
92
110
  - 7
93
111
  version: 0.1.7
94
112
  type: :runtime
95
- version_requirements: *id005
113
+ version_requirements: *id006
96
114
  - !ruby/object:Gem::Dependency
97
- name: em-hiredis
115
+ name: ruby-redis
98
116
  prerelease: false
99
- requirement: &id006 !ruby/object:Gem::Requirement
117
+ requirement: &id007 !ruby/object:Gem::Requirement
100
118
  none: false
101
119
  requirements:
102
120
  - - ">="
@@ -106,11 +124,11 @@ dependencies:
106
124
  - 0
107
125
  version: "0"
108
126
  type: :runtime
109
- version_requirements: *id006
127
+ version_requirements: *id007
110
128
  - !ruby/object:Gem::Dependency
111
129
  name: rack
112
130
  prerelease: false
113
- requirement: &id007 !ruby/object:Gem::Requirement
131
+ requirement: &id008 !ruby/object:Gem::Requirement
114
132
  none: false
115
133
  requirements:
116
134
  - - ~>
@@ -122,11 +140,11 @@ dependencies:
122
140
  - 4
123
141
  version: 1.3.4
124
142
  type: :runtime
125
- version_requirements: *id007
143
+ version_requirements: *id008
126
144
  - !ruby/object:Gem::Dependency
127
145
  name: async_sinatra
128
146
  prerelease: false
129
- requirement: &id008 !ruby/object:Gem::Requirement
147
+ requirement: &id009 !ruby/object:Gem::Requirement
130
148
  none: false
131
149
  requirements:
132
150
  - - ">="
@@ -136,11 +154,11 @@ dependencies:
136
154
  - 0
137
155
  version: "0"
138
156
  type: :runtime
139
- version_requirements: *id008
157
+ version_requirements: *id009
140
158
  - !ruby/object:Gem::Dependency
141
159
  name: thin
142
160
  prerelease: false
143
- requirement: &id009 !ruby/object:Gem::Requirement
161
+ requirement: &id010 !ruby/object:Gem::Requirement
144
162
  none: false
145
163
  requirements:
146
164
  - - ">="
@@ -150,11 +168,11 @@ dependencies:
150
168
  - 0
151
169
  version: "0"
152
170
  type: :runtime
153
- version_requirements: *id009
171
+ version_requirements: *id010
154
172
  - !ruby/object:Gem::Dependency
155
173
  name: rake
156
174
  prerelease: false
157
- requirement: &id010 !ruby/object:Gem::Requirement
175
+ requirement: &id011 !ruby/object:Gem::Requirement
158
176
  none: false
159
177
  requirements:
160
178
  - - ">="
@@ -164,11 +182,11 @@ dependencies:
164
182
  - 0
165
183
  version: "0"
166
184
  type: :development
167
- version_requirements: *id010
185
+ version_requirements: *id011
168
186
  - !ruby/object:Gem::Dependency
169
187
  name: em-spec
170
188
  prerelease: false
171
- requirement: &id011 !ruby/object:Gem::Requirement
189
+ requirement: &id012 !ruby/object:Gem::Requirement
172
190
  none: false
173
191
  requirements:
174
192
  - - ">="
@@ -178,7 +196,21 @@ dependencies:
178
196
  - 0
179
197
  version: "0"
180
198
  type: :development
181
- version_requirements: *id011
199
+ version_requirements: *id012
200
+ - !ruby/object:Gem::Dependency
201
+ name: em-http-request
202
+ prerelease: false
203
+ requirement: &id013 !ruby/object:Gem::Requirement
204
+ none: false
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ hash: 3
209
+ segments:
210
+ - 0
211
+ version: "0"
212
+ type: :development
213
+ version_requirements: *id013
182
214
  description: A monitoring framework that aims to be simple, malleable, and scalable. Uses the publish/subscribe model.
183
215
  email:
184
216
  - sean.porter@sonian.net
@@ -209,7 +241,6 @@ files:
209
241
  - lib/sensu/helpers.rb
210
242
  - lib/sensu/server.rb
211
243
  - sensu.gemspec
212
- - sensu.windows
213
244
  has_rdoc: true
214
245
  homepage: https://github.com/sonian/sensu
215
246
  licenses:
data/sensu.windows DELETED
@@ -1,31 +0,0 @@
1
- require File.expand_path("../lib/sensu", __FILE__)
2
-
3
- Gem::Specification.new do |s|
4
- s.name = "sensu"
5
- s.version = Sensu::VERSION
6
- s.authors = ["Sean Porter", "Justin Kolberg"]
7
- s.email = ["sean.porter@sonian.net", "justin.kolberg@sonian.net"]
8
- s.homepage = "https://github.com/sonian/sensu"
9
- s.summary = %q{A monitoring framework}
10
- s.description = %q{A monitoring framework that aims to be simple, malleable, and scalable. Uses the publish/subscribe model.}
11
- s.license = "MIT"
12
- s.has_rdoc = false
13
-
14
- s.platform = case ENV['BUILD']
15
- when "mswin"
16
- "x86-mswin32"
17
- when "mingw"
18
- "x86-mingw32"
19
- end
20
-
21
- s.add_dependency("eventmachine", "1.0.0.beta.4.1")
22
- s.add_dependency("amqp", "0.7.4")
23
- s.add_dependency("json")
24
- s.add_dependency("hashie")
25
- s.add_dependency("uuidtools")
26
- s.add_dependency("cabin", "0.1.7")
27
-
28
- s.files = `git ls-files`.split("\n").reject {|f| f =~ /(dist|test|server|api|png)/}
29
- s.executables = "sensu-client"
30
- s.require_paths = ["lib"]
31
- end