sensu 0.8.13 → 0.8.16

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -5,7 +5,6 @@ gem("eventmachine", "~> 1.0.0.beta.4")
5
5
  gem("amqp", "0.7.4")
6
6
  gem("json")
7
7
  gem("hashie")
8
- gem("uuidtools")
9
8
  gem("cabin", "0.1.7")
10
9
  gem("ruby-redis-portertech")
11
10
  gem("rack", "~> 1.3.4")
data/Gemfile.lock CHANGED
@@ -27,7 +27,7 @@ GEM
27
27
  eventmachine (1.0.0.beta.4)
28
28
  hashie (1.2.0)
29
29
  http_parser.rb (0.5.3)
30
- json (1.6.1)
30
+ json (1.6.3)
31
31
  rack (1.3.5)
32
32
  rack-protection (1.1.4)
33
33
  rack
@@ -46,13 +46,12 @@ GEM
46
46
  rack (~> 1.3, >= 1.3.4)
47
47
  rack-protection (~> 1.1, >= 1.1.2)
48
48
  tilt (~> 1.3, >= 1.3.3)
49
- test-unit (2.4.1)
49
+ test-unit (2.4.2)
50
50
  thin (1.3.1)
51
51
  daemons (>= 1.0.9)
52
52
  eventmachine (>= 0.12.6)
53
53
  rack (>= 1.0.0)
54
54
  tilt (1.3.3)
55
- uuidtools (2.1.2)
56
55
 
57
56
  PLATFORMS
58
57
  ruby
@@ -71,4 +70,3 @@ DEPENDENCIES
71
70
  rake
72
71
  ruby-redis-portertech
73
72
  thin
74
- uuidtools
data/lib/sensu.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Sensu
2
- VERSION = "0.8.13"
2
+ VERSION = "0.8.16"
3
3
  end
data/lib/sensu/client.rb CHANGED
@@ -55,7 +55,7 @@ module Sensu
55
55
  end
56
56
 
57
57
  def publish_result(check)
58
- @logger.info('[result] -- publishing check result -- ' + check.name)
58
+ @logger.info('[result] -- publishing check result -- ' + check.status.to_s + ' -- ' + check.name)
59
59
  @result_queue ||= @amq.queue('results')
60
60
  @result_queue.publish({
61
61
  :client => @settings.client.name,
@@ -110,7 +110,7 @@ module Sensu
110
110
 
111
111
  def setup_subscriptions
112
112
  @logger.debug('[subscribe] -- setup subscriptions')
113
- @check_queue = @amq.queue(UUIDTools::UUID.random_create.to_s, :exclusive => true)
113
+ @check_queue = @amq.queue(String.unique, :exclusive => true)
114
114
  @settings.client.subscriptions.push('uchiwa')
115
115
  @settings.client.subscriptions.each do |exchange|
116
116
  @logger.debug('[subscribe] -- queue binding to exchange -- ' + exchange)
data/lib/sensu/config.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'rubygems' if RUBY_VERSION < '1.9.0'
2
+ require 'bundler'
2
3
  require 'bundler/setup'
3
4
 
4
5
  require File.join(File.dirname(__FILE__), 'helpers')
@@ -8,7 +9,6 @@ gem 'eventmachine', '~> 1.0.0.beta.4'
8
9
  require 'optparse'
9
10
  require 'json'
10
11
  require 'hashie'
11
- require 'uuidtools'
12
12
  require 'amqp'
13
13
  require 'cabin'
14
14
  require 'cabin/outputs/em-stdlib-logger'
@@ -26,7 +26,10 @@ module Sensu
26
26
  invalid_config('log file is not writable: ' + log_file)
27
27
  end
28
28
  @logger.subscribe(Cabin::Outputs::EmStdlibLogger.new(ruby_logger))
29
- @logger.level = options[:verbose] ? 'debug' : 'info'
29
+ @logger.level = options[:verbose] ? :debug : :info
30
+ Signal.trap('USR1') do
31
+ @logger.level = @logger.level == :info ? :debug : :info
32
+ end
30
33
  config_file = options[:config_file] || '/etc/sensu/config.json'
31
34
  if File.readable?(config_file)
32
35
  begin
data/lib/sensu/helpers.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  class Hash
2
- def symbolize_keys(item = self)
2
+ def symbolize_keys(item=self)
3
3
  case item
4
4
  when Array
5
5
  item.map do |i|
@@ -18,3 +18,9 @@ class Hash
18
18
  end
19
19
  end
20
20
  end
21
+
22
+ class String
23
+ def self.unique(chars=32)
24
+ rand(36**chars).to_s(36)
25
+ end
26
+ end
data/lib/sensu/server.rb CHANGED
@@ -101,7 +101,7 @@ module Sensu
101
101
  end
102
102
 
103
103
  def process_result(result)
104
- @logger.debug('[result] -- processing result for ' + [result.client, result.check.name].join(' -- '))
104
+ @logger.debug('[result] -- processing result -- ' + result.client + ' -- ' + result.check.name)
105
105
  @redis.get('client:' + result.client).callback do |client_json|
106
106
  unless client_json.nil?
107
107
  client = Hashie::Mash.new(JSON.parse(client_json))
@@ -132,20 +132,21 @@ module Sensu
132
132
  total_state_change = (state_changes.fdiv(20) * 100).to_i
133
133
  @redis.lpop(history_key)
134
134
  end
135
- high_flap_threshold = check.high_flap_threshold || 50
136
- low_flap_threshold = check.low_flap_threshold || 40
137
135
  @redis.hget('events:' + client.name, check.name).callback do |event_json|
138
- previous_event = event_json ? Hashie::Mash.new(JSON.parse(event_json)) : false
139
- is_flapping = previous_event ? previous_event.flapping : false
140
- is_flapping = case
141
- when total_state_change >= high_flap_threshold
142
- true
143
- when is_flapping && total_state_change <= low_flap_threshold
144
- false
145
- else
146
- is_flapping
136
+ previous_occurrence = event_json ? Hashie::Mash.new(JSON.parse(event_json)) : false
137
+ is_flapping = false
138
+ if check.key?('low_flap_threshold') && check.key?('high_flap_threshold')
139
+ was_flapping = previous_occurrence ? previous_occurrence.flapping : false
140
+ is_flapping = case
141
+ when total_state_change >= check.high_flap_threshold
142
+ true
143
+ when was_flapping && total_state_change <= check.low_flap_threshold
144
+ false
145
+ else
146
+ was_flapping
147
+ end
147
148
  end
148
- if previous_event && check.status == 0
149
+ if previous_occurrence && check.status == 0
149
150
  unless is_flapping
150
151
  unless check.auto_resolve == false && !check.force_resolve
151
152
  @redis.hdel('events:' + client.name, check.name).callback do
@@ -157,11 +158,11 @@ module Sensu
157
158
  end
158
159
  else
159
160
  @logger.debug('[result] -- check is flapping -- ' + client.name + ' -- ' + check.name)
160
- @redis.hset('events:' + client.name, check.name, previous_event.merge({'flapping' => true}).to_json)
161
+ @redis.hset('events:' + client.name, check.name, previous_occurrence.merge({'flapping' => true}).to_json)
161
162
  end
162
163
  elsif check['status'] != 0
163
- if previous_event && check.status == previous_event.status
164
- event.occurrences = previous_event.occurrences += 1
164
+ if previous_occurrence && check.status == previous_occurrence.status
165
+ event.occurrences = previous_occurrence.occurrences += 1
165
166
  end
166
167
  @redis.hset('events:' + client.name, check.name, {
167
168
  :status => check.status,
@@ -201,7 +202,7 @@ module Sensu
201
202
  @settings.checks.each_with_index do |(name, details), index|
202
203
  check = Hashie::Mash.new
203
204
  check.name = name
204
- unless details.enabled == false
205
+ unless details.publish == false
205
206
  EM.add_timer(stagger*index) do
206
207
  details.subscribers.each do |subscriber|
207
208
  if subscriber.is_a?(Hash)
data/sensu.gemspec CHANGED
@@ -17,7 +17,6 @@ Gem::Specification.new do |s|
17
17
  s.add_dependency("amqp", "0.7.4")
18
18
  s.add_dependency("json")
19
19
  s.add_dependency("hashie")
20
- s.add_dependency("uuidtools")
21
20
  s.add_dependency("cabin", "0.1.7")
22
21
  s.add_dependency("ruby-redis-portertech")
23
22
  s.add_dependency("rack", "~> 1.3.4")
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: 37
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 8
9
- - 13
10
- version: 0.8.13
9
+ - 16
10
+ version: 0.8.16
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sean Porter
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-11-22 00:00:00 -08:00
19
+ date: 2011-12-02 00:00:00 -08:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -95,24 +95,10 @@ dependencies:
95
95
  version: "0"
96
96
  type: :runtime
97
97
  version_requirements: *id005
98
- - !ruby/object:Gem::Dependency
99
- name: uuidtools
100
- prerelease: false
101
- requirement: &id006 !ruby/object:Gem::Requirement
102
- none: false
103
- requirements:
104
- - - ">="
105
- - !ruby/object:Gem::Version
106
- hash: 3
107
- segments:
108
- - 0
109
- version: "0"
110
- type: :runtime
111
- version_requirements: *id006
112
98
  - !ruby/object:Gem::Dependency
113
99
  name: cabin
114
100
  prerelease: false
115
- requirement: &id007 !ruby/object:Gem::Requirement
101
+ requirement: &id006 !ruby/object:Gem::Requirement
116
102
  none: false
117
103
  requirements:
118
104
  - - "="
@@ -124,11 +110,11 @@ dependencies:
124
110
  - 7
125
111
  version: 0.1.7
126
112
  type: :runtime
127
- version_requirements: *id007
113
+ version_requirements: *id006
128
114
  - !ruby/object:Gem::Dependency
129
115
  name: ruby-redis-portertech
130
116
  prerelease: false
131
- requirement: &id008 !ruby/object:Gem::Requirement
117
+ requirement: &id007 !ruby/object:Gem::Requirement
132
118
  none: false
133
119
  requirements:
134
120
  - - ">="
@@ -138,11 +124,11 @@ dependencies:
138
124
  - 0
139
125
  version: "0"
140
126
  type: :runtime
141
- version_requirements: *id008
127
+ version_requirements: *id007
142
128
  - !ruby/object:Gem::Dependency
143
129
  name: rack
144
130
  prerelease: false
145
- requirement: &id009 !ruby/object:Gem::Requirement
131
+ requirement: &id008 !ruby/object:Gem::Requirement
146
132
  none: false
147
133
  requirements:
148
134
  - - ~>
@@ -154,11 +140,11 @@ dependencies:
154
140
  - 4
155
141
  version: 1.3.4
156
142
  type: :runtime
157
- version_requirements: *id009
143
+ version_requirements: *id008
158
144
  - !ruby/object:Gem::Dependency
159
145
  name: async_sinatra
160
146
  prerelease: false
161
- requirement: &id010 !ruby/object:Gem::Requirement
147
+ requirement: &id009 !ruby/object:Gem::Requirement
162
148
  none: false
163
149
  requirements:
164
150
  - - ">="
@@ -168,11 +154,11 @@ dependencies:
168
154
  - 0
169
155
  version: "0"
170
156
  type: :runtime
171
- version_requirements: *id010
157
+ version_requirements: *id009
172
158
  - !ruby/object:Gem::Dependency
173
159
  name: thin
174
160
  prerelease: false
175
- requirement: &id011 !ruby/object:Gem::Requirement
161
+ requirement: &id010 !ruby/object:Gem::Requirement
176
162
  none: false
177
163
  requirements:
178
164
  - - ">="
@@ -182,11 +168,11 @@ dependencies:
182
168
  - 0
183
169
  version: "0"
184
170
  type: :runtime
185
- version_requirements: *id011
171
+ version_requirements: *id010
186
172
  - !ruby/object:Gem::Dependency
187
173
  name: rake
188
174
  prerelease: false
189
- requirement: &id012 !ruby/object:Gem::Requirement
175
+ requirement: &id011 !ruby/object:Gem::Requirement
190
176
  none: false
191
177
  requirements:
192
178
  - - ">="
@@ -196,11 +182,11 @@ dependencies:
196
182
  - 0
197
183
  version: "0"
198
184
  type: :development
199
- version_requirements: *id012
185
+ version_requirements: *id011
200
186
  - !ruby/object:Gem::Dependency
201
187
  name: em-spec
202
188
  prerelease: false
203
- requirement: &id013 !ruby/object:Gem::Requirement
189
+ requirement: &id012 !ruby/object:Gem::Requirement
204
190
  none: false
205
191
  requirements:
206
192
  - - ">="
@@ -210,11 +196,11 @@ dependencies:
210
196
  - 0
211
197
  version: "0"
212
198
  type: :development
213
- version_requirements: *id013
199
+ version_requirements: *id012
214
200
  - !ruby/object:Gem::Dependency
215
201
  name: em-http-request
216
202
  prerelease: false
217
- requirement: &id014 !ruby/object:Gem::Requirement
203
+ requirement: &id013 !ruby/object:Gem::Requirement
218
204
  none: false
219
205
  requirements:
220
206
  - - ">="
@@ -224,7 +210,7 @@ dependencies:
224
210
  - 0
225
211
  version: "0"
226
212
  type: :development
227
- version_requirements: *id014
213
+ version_requirements: *id013
228
214
  description: A monitoring framework that aims to be simple, malleable, and scalable. Uses the publish/subscribe model.
229
215
  email:
230
216
  - sean.porter@sonian.net