sensu 0.9.6.beta.2 → 0.9.6.beta.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/sensu/api.rb +13 -19
- data/lib/sensu/constants.rb +1 -1
- data/lib/sensu/server.rb +1 -0
- metadata +4 -4
data/lib/sensu/api.rb
CHANGED
@@ -58,18 +58,23 @@ module Sensu
|
|
58
58
|
|
59
59
|
configure do
|
60
60
|
disable :protection
|
61
|
+
disable :show_exceptions
|
61
62
|
end
|
62
63
|
|
63
64
|
not_found do
|
64
65
|
''
|
65
66
|
end
|
66
67
|
|
68
|
+
error do
|
69
|
+
''
|
70
|
+
end
|
71
|
+
|
67
72
|
before do
|
68
73
|
content_type 'application/json'
|
74
|
+
request_log(env)
|
69
75
|
end
|
70
76
|
|
71
77
|
aget '/info' do
|
72
|
-
request_log(env)
|
73
78
|
response = {
|
74
79
|
:sensu => {
|
75
80
|
:version => VERSION
|
@@ -89,7 +94,6 @@ module Sensu
|
|
89
94
|
end
|
90
95
|
|
91
96
|
aget '/clients' do
|
92
|
-
request_log(env)
|
93
97
|
response = Array.new
|
94
98
|
$redis.smembers('clients').callback do |clients|
|
95
99
|
unless clients.empty?
|
@@ -108,7 +112,6 @@ module Sensu
|
|
108
112
|
end
|
109
113
|
|
110
114
|
aget '/client/:name' do |client_name|
|
111
|
-
request_log(env)
|
112
115
|
$redis.get('client:' + client_name).callback do |client_json|
|
113
116
|
unless client_json.nil?
|
114
117
|
body client_json
|
@@ -120,7 +123,6 @@ module Sensu
|
|
120
123
|
end
|
121
124
|
|
122
125
|
adelete '/client/:name' do |client_name|
|
123
|
-
request_log(env)
|
124
126
|
$redis.get('client:' + client_name).callback do |client_json|
|
125
127
|
unless client_json.nil?
|
126
128
|
client = JSON.parse(client_json, :symbolize_names => true)
|
@@ -148,8 +150,11 @@ module Sensu
|
|
148
150
|
$redis.srem('clients', client_name)
|
149
151
|
$redis.del('events:' + client_name)
|
150
152
|
$redis.del('client:' + client_name)
|
151
|
-
$
|
152
|
-
|
153
|
+
$redis.smembers('history:' + client_name).callback do |checks|
|
154
|
+
checks.each do |check_name|
|
155
|
+
$redis.del('history:' + client_name + ':' + check_name)
|
156
|
+
end
|
157
|
+
$redis.del('history:' + client_name)
|
153
158
|
end
|
154
159
|
end
|
155
160
|
status 204
|
@@ -163,12 +168,10 @@ module Sensu
|
|
163
168
|
end
|
164
169
|
|
165
170
|
aget '/checks' do
|
166
|
-
request_log(env)
|
167
171
|
body $settings.checks.to_json
|
168
172
|
end
|
169
173
|
|
170
174
|
aget '/check/:name' do |check_name|
|
171
|
-
request_log(env)
|
172
175
|
if $settings.check_exists?(check_name)
|
173
176
|
response = $settings[:checks][check_name].merge(:name => check_name)
|
174
177
|
body response.to_json
|
@@ -179,14 +182,13 @@ module Sensu
|
|
179
182
|
end
|
180
183
|
|
181
184
|
apost '/check/request' do
|
182
|
-
request_log(env)
|
183
185
|
begin
|
184
186
|
post_body = JSON.parse(request.body.read, :symbolize_names => true)
|
185
187
|
rescue JSON::ParserError
|
186
188
|
status 400
|
187
189
|
body ''
|
188
190
|
end
|
189
|
-
if post_body[:check].is_a?(String) && post_body[:subscribers].is_a?(Array)
|
191
|
+
if post_body.is_a?(Hash) && post_body[:check].is_a?(String) && post_body[:subscribers].is_a?(Array)
|
190
192
|
payload = {
|
191
193
|
:name => post_body[:check],
|
192
194
|
:issued => Time.now.to_i
|
@@ -206,7 +208,6 @@ module Sensu
|
|
206
208
|
end
|
207
209
|
|
208
210
|
aget '/events' do
|
209
|
-
request_log(env)
|
210
211
|
response = Array.new
|
211
212
|
$redis.smembers('clients').callback do |clients|
|
212
213
|
unless clients.empty?
|
@@ -227,7 +228,6 @@ module Sensu
|
|
227
228
|
end
|
228
229
|
|
229
230
|
aget '/event/:client/:check' do |client_name, check_name|
|
230
|
-
request_log(env)
|
231
231
|
$redis.hgetall('events:' + client_name).callback do |events|
|
232
232
|
event_json = events[check_name]
|
233
233
|
unless event_json.nil?
|
@@ -241,14 +241,13 @@ module Sensu
|
|
241
241
|
end
|
242
242
|
|
243
243
|
apost '/event/resolve' do
|
244
|
-
request_log(env)
|
245
244
|
begin
|
246
245
|
post_body = JSON.parse(request.body.read, :symbolize_names => true)
|
247
246
|
rescue JSON::ParserError
|
248
247
|
status 400
|
249
248
|
body ''
|
250
249
|
end
|
251
|
-
if post_body[:client].is_a?(String) && post_body[:check].is_a?(String)
|
250
|
+
if post_body.is_a?(Hash) && post_body[:client].is_a?(String) && post_body[:check].is_a?(String)
|
252
251
|
$redis.hgetall('events:' + post_body[:client]).callback do |events|
|
253
252
|
if events.include?(post_body[:check])
|
254
253
|
payload = {
|
@@ -278,7 +277,6 @@ module Sensu
|
|
278
277
|
end
|
279
278
|
|
280
279
|
apost '/stash/*' do |path|
|
281
|
-
request_log(env)
|
282
280
|
begin
|
283
281
|
post_body = JSON.parse(request.body.read)
|
284
282
|
rescue JSON::ParserError
|
@@ -294,7 +292,6 @@ module Sensu
|
|
294
292
|
end
|
295
293
|
|
296
294
|
aget '/stash/*' do |path|
|
297
|
-
request_log(env)
|
298
295
|
$redis.get('stash:' + path).callback do |stash_json|
|
299
296
|
if stash_json.nil?
|
300
297
|
status 404
|
@@ -306,7 +303,6 @@ module Sensu
|
|
306
303
|
end
|
307
304
|
|
308
305
|
adelete '/stash/*' do |path|
|
309
|
-
request_log(env)
|
310
306
|
$redis.exists('stash:' + path).callback do |stash_exists|
|
311
307
|
if stash_exists
|
312
308
|
$redis.srem('stashes', path).callback do
|
@@ -323,14 +319,12 @@ module Sensu
|
|
323
319
|
end
|
324
320
|
|
325
321
|
aget '/stashes' do
|
326
|
-
request_log(env)
|
327
322
|
$redis.smembers('stashes') do |stashes|
|
328
323
|
body stashes.to_json
|
329
324
|
end
|
330
325
|
end
|
331
326
|
|
332
327
|
apost '/stashes' do
|
333
|
-
request_log(env)
|
334
328
|
begin
|
335
329
|
post_body = JSON.parse(request.body.read)
|
336
330
|
rescue JSON::ParserError
|
data/lib/sensu/constants.rb
CHANGED
data/lib/sensu/server.rb
CHANGED
@@ -182,6 +182,7 @@ module Sensu
|
|
182
182
|
:check => check,
|
183
183
|
:occurrences => 1
|
184
184
|
}
|
185
|
+
@redis.sadd('history:' + client[:name], check[:name])
|
185
186
|
history_key = 'history:' + client[:name] + ':' + check[:name]
|
186
187
|
@redis.rpush(history_key, check[:status]).callback do
|
187
188
|
@redis.lrange(history_key, -21, -1).callback do |history|
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 62196229
|
5
5
|
prerelease: true
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 9
|
9
9
|
- 6
|
10
10
|
- beta
|
11
|
-
-
|
12
|
-
version: 0.9.6.beta.
|
11
|
+
- 3
|
12
|
+
version: 0.9.6.beta.3
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- Sean Porter
|
@@ -18,7 +18,7 @@ autorequire:
|
|
18
18
|
bindir: bin
|
19
19
|
cert_chain: []
|
20
20
|
|
21
|
-
date: 2012-05-
|
21
|
+
date: 2012-05-04 00:00:00 -07:00
|
22
22
|
default_executable:
|
23
23
|
dependencies:
|
24
24
|
- !ruby/object:Gem::Dependency
|