sensu 1.1.3 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -0
- data/README.md +1 -0
- data/lib/sensu/api/http_handler.rb +14 -2
- data/lib/sensu/api/routes/results.rb +36 -15
- data/lib/sensu/api/routes/silenced.rb +10 -2
- data/lib/sensu/constants.rb +1 -1
- data/lib/sensu/daemon.rb +1 -1
- data/lib/sensu/server/process.rb +4 -1
- data/sensu.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 033a973109e8bcb6bb775163452c270b74907afe
|
4
|
+
data.tar.gz: 464a435d9c1191d9e8b941681c8b53af57977940
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be59c0a1d75341cfec86f91e29f978c8c5a5a629cad565918d253f687e72958c18a037f4919d04746802da3ddab4a7664388c6538f2eaf24a4fa01b9795f2d5d
|
7
|
+
data.tar.gz: 4775c24d752d40cc2ae90795a80ff81095796a4aabd0d5d9b719e58d45c80ac74b6f9234f6e3d321c41c7505941f7ec8424573e0845d5dd06618ab8ab54b9632
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,21 @@
|
|
1
|
+
## 1.2.0 - 2017-12-05
|
2
|
+
|
3
|
+
### Features
|
4
|
+
|
5
|
+
Scheduled maintenance, Sensu now gives users the ability to silence a
|
6
|
+
check and/or client subscriptions at a predetermined time (`begin`
|
7
|
+
epoch timestamp), with an optional expiration (in seconds), enabling
|
8
|
+
users to silence events in advance for scheduled maintenance windows.
|
9
|
+
|
10
|
+
The Sensu API now logs the "X-Request-ID" header, making it much
|
11
|
+
easier to trace a request/response. If the API client does not provide
|
12
|
+
a request ID, the API generates one for the request (UUID).
|
13
|
+
|
14
|
+
The Sensu API `/results/*` endpoints now include check history in the
|
15
|
+
result data.
|
16
|
+
|
17
|
+
Check token substitution is now supported in check "subdue".
|
18
|
+
|
1
19
|
## 1.1.3 - 2017-11-24
|
2
20
|
|
3
21
|
### Fixes
|
data/README.md
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
[![Build Status](https://img.shields.io/travis/sensu/sensu.svg)](https://travis-ci.org/sensu/sensu)
|
4
4
|
[![Gem Version](https://img.shields.io/gem/v/sensu.svg)](https://github.com/sensu/sensu/blob/master/CHANGELOG.md)
|
5
5
|
[![MIT Licensed](https://img.shields.io/github/license/sensu/sensu.svg)](https://raw.githubusercontent.com/sensu/sensu/master/MIT-LICENSE.txt)
|
6
|
+
[![Join the chat at https://slack.sensu.io/](https://slack.sensu.io/badge.svg)](https://slack.sensu.io/)
|
6
7
|
|
7
8
|
# Sensu
|
8
9
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require "sensu/utilities"
|
1
2
|
require "sensu/api/routes"
|
2
3
|
require "sensu/api/utilities/filter_response_content"
|
3
4
|
|
@@ -21,9 +22,11 @@ module Sensu
|
|
21
22
|
# @result [Hash]
|
22
23
|
def request_details
|
23
24
|
return @request_details if @request_details
|
25
|
+
@request_id = @http.fetch(:x_request_id, random_uuid)
|
24
26
|
@request_start_time = Time.now.to_f
|
25
27
|
_, remote_address = Socket.unpack_sockaddr_in(get_peername)
|
26
28
|
@request_details = {
|
29
|
+
:request_id => @request_id,
|
27
30
|
:remote_address => remote_address,
|
28
31
|
:user_agent => @http[:user_agent],
|
29
32
|
:method => @http_request_method,
|
@@ -44,7 +47,9 @@ module Sensu
|
|
44
47
|
end
|
45
48
|
|
46
49
|
# Log the HTTP response. This method calculates the
|
47
|
-
# request/response time.
|
50
|
+
# request/response time. The debug log level is used for the
|
51
|
+
# response body log event, as it is generally very verbose and
|
52
|
+
# unnecessary in most cases.
|
48
53
|
def log_response
|
49
54
|
@logger.info("api response", {
|
50
55
|
:request => request_details,
|
@@ -148,6 +153,13 @@ module Sensu
|
|
148
153
|
end
|
149
154
|
end
|
150
155
|
|
156
|
+
# Set the HTTP response headers, including the request ID and
|
157
|
+
# cors headers (via `set_cores_headers()`).
|
158
|
+
def set_headers
|
159
|
+
@response.headers["X-Request-ID"] = @request_id
|
160
|
+
set_cors_headers
|
161
|
+
end
|
162
|
+
|
151
163
|
# Paginate the provided items. This method uses two HTTP query
|
152
164
|
# parameters to determine how to paginate the items, `limit` and
|
153
165
|
# `offset`. The parameter `limit` specifies how many items are
|
@@ -392,7 +404,7 @@ module Sensu
|
|
392
404
|
log_request
|
393
405
|
parse_parameters
|
394
406
|
create_response
|
395
|
-
|
407
|
+
set_headers
|
396
408
|
if authorized?
|
397
409
|
if connected?
|
398
410
|
route_request
|
@@ -36,12 +36,19 @@ module Sensu
|
|
36
36
|
checks.each_with_index do |check_name, check_index|
|
37
37
|
result_key = "result:#{client_name}:#{check_name}"
|
38
38
|
@redis.get(result_key) do |result_json|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
39
|
+
history_key = "history:#{client_name}:#{check_name}"
|
40
|
+
@redis.lrange(history_key, -21, -1) do |history|
|
41
|
+
history.map! do |status|
|
42
|
+
status.to_i
|
43
|
+
end
|
44
|
+
unless result_json.nil?
|
45
|
+
check = Sensu::JSON.load(result_json)
|
46
|
+
check[:history] = history
|
47
|
+
@response_content << {:client => client_name, :check => check}
|
48
|
+
end
|
49
|
+
if client_index == clients.length - 1 && check_index == checks.length - 1
|
50
|
+
respond
|
51
|
+
end
|
45
52
|
end
|
46
53
|
end
|
47
54
|
end
|
@@ -67,12 +74,19 @@ module Sensu
|
|
67
74
|
checks.each_with_index do |check_name, check_index|
|
68
75
|
result_key = "result:#{client_name}:#{check_name}"
|
69
76
|
@redis.get(result_key) do |result_json|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
77
|
+
history_key = "history:#{client_name}:#{check_name}"
|
78
|
+
@redis.lrange(history_key, -21, -1) do |history|
|
79
|
+
history.map! do |status|
|
80
|
+
status.to_i
|
81
|
+
end
|
82
|
+
unless result_json.nil?
|
83
|
+
check = Sensu::JSON.load(result_json)
|
84
|
+
check[:history] = history
|
85
|
+
@response_content << {:client => client_name, :check => check}
|
86
|
+
end
|
87
|
+
if check_index == checks.length - 1
|
88
|
+
respond
|
89
|
+
end
|
76
90
|
end
|
77
91
|
end
|
78
92
|
end
|
@@ -88,9 +102,16 @@ module Sensu
|
|
88
102
|
result_key = "result:#{client_name}:#{check_name}"
|
89
103
|
@redis.get(result_key) do |result_json|
|
90
104
|
unless result_json.nil?
|
91
|
-
|
92
|
-
@
|
93
|
-
|
105
|
+
history_key = "history:#{client_name}:#{check_name}"
|
106
|
+
@redis.lrange(history_key, -21, -1) do |history|
|
107
|
+
history.map! do |status|
|
108
|
+
status.to_i
|
109
|
+
end
|
110
|
+
check = Sensu::JSON.load(result_json)
|
111
|
+
check[:history] = history
|
112
|
+
@response_content = {:client => client_name, :check => check}
|
113
|
+
respond
|
114
|
+
end
|
94
115
|
else
|
95
116
|
not_found!
|
96
117
|
end
|
@@ -48,6 +48,7 @@ module Sensu
|
|
48
48
|
rules = {
|
49
49
|
:subscription => {:type => String, :nil_ok => true, :regex => /\A[\w\.\-\:]+\z/},
|
50
50
|
:check => {:type => String, :nil_ok => true, :regex => /\A[\w\.-]+\z/},
|
51
|
+
:begin => {:type => Integer, :nil_ok => true},
|
51
52
|
:expire => {:type => Integer, :nil_ok => true},
|
52
53
|
:reason => {:type => String, :nil_ok => true},
|
53
54
|
:creator => {:type => String, :nil_ok => true},
|
@@ -58,20 +59,27 @@ module Sensu
|
|
58
59
|
subscription = data.fetch(:subscription, "*")
|
59
60
|
check = data.fetch(:check, "*")
|
60
61
|
silenced_id = "#{subscription}:#{check}"
|
62
|
+
timestamp = Time.now.to_i
|
61
63
|
silenced_info = {
|
62
64
|
:id => silenced_id,
|
63
65
|
:subscription => data[:subscription],
|
64
66
|
:check => data[:check],
|
65
67
|
:reason => data[:reason],
|
66
68
|
:creator => data[:creator],
|
69
|
+
:begin => data[:begin],
|
67
70
|
:expire_on_resolve => data.fetch(:expire_on_resolve, false),
|
68
|
-
:timestamp =>
|
71
|
+
:timestamp => timestamp
|
69
72
|
}
|
70
73
|
silenced_key = "silence:#{silenced_id}"
|
71
74
|
@redis.set(silenced_key, Sensu::JSON.dump(silenced_info)) do
|
72
75
|
@redis.sadd("silenced", silenced_key) do
|
73
76
|
if data[:expire]
|
74
|
-
|
77
|
+
expire = data[:expire]
|
78
|
+
if data[:begin]
|
79
|
+
diff = data[:begin] - timestamp
|
80
|
+
expire += diff if diff > 0
|
81
|
+
end
|
82
|
+
@redis.expire(silenced_key, expire) do
|
75
83
|
created!
|
76
84
|
end
|
77
85
|
else
|
data/lib/sensu/constants.rb
CHANGED
data/lib/sensu/daemon.rb
CHANGED
data/lib/sensu/server/process.rb
CHANGED
@@ -485,7 +485,7 @@ module Sensu
|
|
485
485
|
silenced_key = "silence:#{silenced_info[:id]}"
|
486
486
|
@redis.srem("silenced", silenced_key)
|
487
487
|
@redis.del(silenced_key)
|
488
|
-
|
488
|
+
elsif silenced_info[:begin].nil? || silenced_info[:begin] <= Time.now.to_i
|
489
489
|
event[:silenced_by] << silenced_info[:id]
|
490
490
|
end
|
491
491
|
end
|
@@ -1065,6 +1065,9 @@ module Sensu
|
|
1065
1065
|
if @settings.handler_exists?(:keepalive)
|
1066
1066
|
check[:handler] = "keepalive"
|
1067
1067
|
end
|
1068
|
+
if @settings[:sensu][:keepalives]
|
1069
|
+
check = deep_merge(check, @settings[:sensu][:keepalives])
|
1070
|
+
end
|
1068
1071
|
if client.has_key?(:keepalive)
|
1069
1072
|
check = deep_merge(check, client[:keepalive])
|
1070
1073
|
end
|
data/sensu.gemspec
CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.add_dependency "eventmachine", "1.2.5"
|
16
16
|
s.add_dependency "sensu-json", "2.1.0"
|
17
17
|
s.add_dependency "sensu-logger", "1.2.1"
|
18
|
-
s.add_dependency "sensu-settings", "10.
|
18
|
+
s.add_dependency "sensu-settings", "10.12.0"
|
19
19
|
s.add_dependency "sensu-extension", "1.5.1"
|
20
20
|
s.add_dependency "sensu-extensions", "1.9.0"
|
21
21
|
s.add_dependency "sensu-transport", "7.0.2"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Porter
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-12-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: eventmachine
|
@@ -59,14 +59,14 @@ dependencies:
|
|
59
59
|
requirements:
|
60
60
|
- - '='
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: 10.
|
62
|
+
version: 10.12.0
|
63
63
|
type: :runtime
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
67
|
- - '='
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: 10.
|
69
|
+
version: 10.12.0
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: sensu-extension
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|