sensu 0.9.12.beta.4 → 0.9.12.beta.5
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 +2 -0
- data/README.md +1 -1
- data/lib/sensu/api.rb +36 -2
- data/lib/sensu/client.rb +3 -0
- data/lib/sensu/constants.rb +1 -1
- data/lib/sensu/server.rb +4 -1
- metadata +4 -4
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
A monitoring framework that aims to be simple, malleable, and scalable.
|
|
4
4
|
|
|
5
|
-
](https://travis-ci.org/sensu/sensu)
|
|
6
6
|
|
|
7
7
|
## Documentation
|
|
8
8
|
Please refer to the [Sensu Wiki](https://github.com/sensu/sensu/wiki).
|
data/lib/sensu/api.rb
CHANGED
|
@@ -253,6 +253,39 @@ module Sensu
|
|
|
253
253
|
end
|
|
254
254
|
end
|
|
255
255
|
|
|
256
|
+
aget %r{/clients/([\w\.-]+)/history$} do |client_name|
|
|
257
|
+
response = Array.new
|
|
258
|
+
$redis.smembers('history:' + client_name) do |checks|
|
|
259
|
+
unless checks.empty?
|
|
260
|
+
checks.each_with_index do |check_name, index|
|
|
261
|
+
history_key = 'history:' + client_name + ':' + check_name
|
|
262
|
+
$redis.lrange(history_key, -21, -1) do |history|
|
|
263
|
+
history.map! do |status|
|
|
264
|
+
status.to_i
|
|
265
|
+
end
|
|
266
|
+
execution_key = 'execution:' + client_name + ':' + check_name
|
|
267
|
+
$redis.get(execution_key) do |last_execution|
|
|
268
|
+
unless history.empty? || last_execution.nil?
|
|
269
|
+
item = {
|
|
270
|
+
:check => check_name,
|
|
271
|
+
:history => history,
|
|
272
|
+
:last_execution => last_execution.to_i,
|
|
273
|
+
:last_status => history.last
|
|
274
|
+
}
|
|
275
|
+
response << item
|
|
276
|
+
end
|
|
277
|
+
if index == checks.size - 1
|
|
278
|
+
body Oj.dump(response)
|
|
279
|
+
end
|
|
280
|
+
end
|
|
281
|
+
end
|
|
282
|
+
end
|
|
283
|
+
else
|
|
284
|
+
body Oj.dump(response)
|
|
285
|
+
end
|
|
286
|
+
end
|
|
287
|
+
end
|
|
288
|
+
|
|
256
289
|
adelete %r{/clients?/([\w\.-]+)$} do |client_name|
|
|
257
290
|
$redis.get('client:' + client_name) do |client_json|
|
|
258
291
|
unless client_json.nil?
|
|
@@ -271,6 +304,7 @@ module Sensu
|
|
|
271
304
|
$redis.smembers('history:' + client_name) do |checks|
|
|
272
305
|
checks.each do |check_name|
|
|
273
306
|
$redis.del('history:' + client_name + ':' + check_name)
|
|
307
|
+
$redis.del('execution:' + client_name + ':' + check_name)
|
|
274
308
|
end
|
|
275
309
|
$redis.del('history:' + client_name)
|
|
276
310
|
end
|
|
@@ -411,11 +445,11 @@ module Sensu
|
|
|
411
445
|
unless checks.empty?
|
|
412
446
|
checks.each_with_index do |check_name, index|
|
|
413
447
|
$redis.smembers('aggregates:' + check_name) do |aggregates|
|
|
414
|
-
|
|
448
|
+
item = {
|
|
415
449
|
:check => check_name,
|
|
416
450
|
:issued => aggregates.sort.reverse
|
|
417
451
|
}
|
|
418
|
-
response <<
|
|
452
|
+
response << item
|
|
419
453
|
if index == checks.size - 1
|
|
420
454
|
body Oj.dump(response)
|
|
421
455
|
end
|
data/lib/sensu/client.rb
CHANGED
|
@@ -97,6 +97,7 @@ module Sensu
|
|
|
97
97
|
unless @checks_in_progress.include?(check[:name])
|
|
98
98
|
@checks_in_progress << check[:name]
|
|
99
99
|
command, unmatched_tokens = substitute_command_tokens(check)
|
|
100
|
+
check[:executed] = Time.now.to_i
|
|
100
101
|
if unmatched_tokens.empty?
|
|
101
102
|
execute = Proc.new do
|
|
102
103
|
@logger.debug('executing check command', {
|
|
@@ -135,6 +136,7 @@ module Sensu
|
|
|
135
136
|
@logger.debug('attempting to run check extension', {
|
|
136
137
|
:check => check
|
|
137
138
|
})
|
|
139
|
+
check[:executed] = Time.now.to_i
|
|
138
140
|
extension = @extensions[:checks][check[:name]]
|
|
139
141
|
extension.run do |output, status|
|
|
140
142
|
check[:output] = output
|
|
@@ -155,6 +157,7 @@ module Sensu
|
|
|
155
157
|
check[:output] = 'Check is not locally defined (safe mode)'
|
|
156
158
|
check[:status] = 3
|
|
157
159
|
check[:handle] = false
|
|
160
|
+
check[:executed] = Time.now.to_i
|
|
158
161
|
publish_result(check)
|
|
159
162
|
else
|
|
160
163
|
execute_check_command(check)
|
data/lib/sensu/constants.rb
CHANGED
data/lib/sensu/server.rb
CHANGED
|
@@ -427,6 +427,8 @@ module Sensu
|
|
|
427
427
|
@redis.sadd('history:' + client[:name], check[:name])
|
|
428
428
|
history_key = 'history:' + client[:name] + ':' + check[:name]
|
|
429
429
|
@redis.rpush(history_key, check[:status]) do
|
|
430
|
+
execution_key = 'execution:' + client[:name] + ':' + check[:name]
|
|
431
|
+
@redis.set(execution_key, check[:executed])
|
|
430
432
|
@redis.lrange(history_key, -21, -1) do |history|
|
|
431
433
|
check[:history] = history
|
|
432
434
|
total_state_change = 0
|
|
@@ -584,7 +586,8 @@ module Sensu
|
|
|
584
586
|
client = Oj.load(client_json)
|
|
585
587
|
check = {
|
|
586
588
|
:name => 'keepalive',
|
|
587
|
-
:issued => Time.now.to_i
|
|
589
|
+
:issued => Time.now.to_i,
|
|
590
|
+
:executed => Time.now.to_i
|
|
588
591
|
}
|
|
589
592
|
time_since_last_keepalive = Time.now.to_i - client[:timestamp]
|
|
590
593
|
case
|
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: -1667026956
|
|
5
5
|
prerelease: true
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
8
|
- 9
|
|
9
9
|
- 12
|
|
10
10
|
- beta
|
|
11
|
-
-
|
|
12
|
-
version: 0.9.12.beta.
|
|
11
|
+
- 5
|
|
12
|
+
version: 0.9.12.beta.5
|
|
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: 2013-03-
|
|
21
|
+
date: 2013-03-14 00:00:00 -07:00
|
|
22
22
|
default_executable:
|
|
23
23
|
dependencies:
|
|
24
24
|
- !ruby/object:Gem::Dependency
|