sensu 0.27.0.alpha.2 → 0.27.0.beta.1
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +35 -0
- data/lib/sensu/client/http_socket.rb +30 -11
- data/lib/sensu/client/process.rb +35 -16
- data/lib/sensu/constants.rb +1 -1
- data/lib/sensu/daemon.rb +1 -1
- data/lib/sensu/server/process.rb +15 -7
- 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: 768682063e96780394b30a632d9f63ea18184421
|
4
|
+
data.tar.gz: 4e9c6427994c6a6c395b7b588b35d6a558648032
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc2ef82b079573a137a4f943b074717565b7c503382999f82bf4db1536cec474cf65cae07b8393af75d013c63312da14caaba9de3fa73c2df567967bcf073830
|
7
|
+
data.tar.gz: 3fdca42dd2b54258dd3aefdd7c20306df1fd3f97fc69ee7193d8dbe927519ef28e17e6f83159d5c18f6fd3930ee14ac82666a7fa3eced8cabde81a96c842cd7a
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,38 @@
|
|
1
|
+
## 0.27.0 - TBD
|
2
|
+
|
3
|
+
### Features
|
4
|
+
|
5
|
+
Sensu client HTTP socket for check result input and informational queries.
|
6
|
+
The client HTTP socket provides several endpoints, `/info`, `/results`,
|
7
|
+
and `/settings`. Basic authentication is supported, which is required for
|
8
|
+
certain endpoints, i.e. `/settings`. The client HTTP socket is
|
9
|
+
configurable via the Sensu client definition, `"http_socket": {}`.
|
10
|
+
|
11
|
+
Hostnames are now resolved prior to making connection attempts, this
|
12
|
+
applies to the Sensu Transport (i.e. RabbitMQ) and Redis connections. This
|
13
|
+
allows Sensu to handle resolution failures and enables failover via DNS
|
14
|
+
and services like Amazon AWS ElastiCache.
|
15
|
+
|
16
|
+
Added API endpoint `/silenced/ids/:id` for fetching a silence entry by id.
|
17
|
+
|
18
|
+
Added check attribute `ttl_status`, allowing checks to set a different TTL
|
19
|
+
event check status (default is `1` warning).
|
20
|
+
|
21
|
+
Added client deregistration attribute `status`, allowing clients to set a
|
22
|
+
different event check status for their deregistration events (default is
|
23
|
+
`1` warning).
|
24
|
+
|
25
|
+
Added Rubygems cleanup support to `sensu-install`, via the command line
|
26
|
+
argument `-c/--clean` when installing one or more plugins and/or
|
27
|
+
extensions. If a version is provided for the plugin(s) or extension(s),
|
28
|
+
all other installed versions of them will be removed, e.g. `sensu-install
|
29
|
+
-e snmp-trap:0.0.19 -c`. If a version is not provided, all installed
|
30
|
+
versions except the latest will be removed.
|
31
|
+
|
32
|
+
### Other
|
33
|
+
|
34
|
+
Added the filter name to event filtered log events.
|
35
|
+
|
1
36
|
## 0.26.5 - 2016-10-12
|
2
37
|
|
3
38
|
### Fixes
|
@@ -88,7 +88,11 @@ module Sensu
|
|
88
88
|
end
|
89
89
|
|
90
90
|
def send_response(status, status_string, content)
|
91
|
-
@logger.debug("sending
|
91
|
+
@logger.debug("http socket sending response", {
|
92
|
+
:status => status,
|
93
|
+
:status_string => status_string,
|
94
|
+
:content => content
|
95
|
+
})
|
92
96
|
@response.status = status
|
93
97
|
@response.status_string = status_string
|
94
98
|
@response.content = Sensu::JSON::dump(content)
|
@@ -111,7 +115,7 @@ module Sensu
|
|
111
115
|
begin
|
112
116
|
check = Sensu::JSON::load(@http_content)
|
113
117
|
process_check_result(check)
|
114
|
-
send_response(
|
118
|
+
send_response(202, "OK", {:response => "ok"})
|
115
119
|
rescue Sensu::JSON::ParseError, ArgumentError
|
116
120
|
send_response(400, "Failed to parse JSON body", {:response => "Failed to parse JSON body"})
|
117
121
|
end
|
@@ -122,14 +126,14 @@ module Sensu
|
|
122
126
|
|
123
127
|
def process_request_settings
|
124
128
|
if authorized?
|
125
|
-
@logger.info("responding to
|
129
|
+
@logger.info("http socket responding to request for configuration settings")
|
126
130
|
if @http_query_string and @http_query_string.downcase.include?("redacted=false")
|
127
131
|
send_response(200, "OK", @settings.to_hash)
|
128
132
|
else
|
129
133
|
send_response(200, "OK", redact_sensitive(@settings.to_hash))
|
130
134
|
end
|
131
135
|
else
|
132
|
-
@logger.warn("refusing to serve unauthorized settings request")
|
136
|
+
@logger.warn("http socket refusing to serve unauthorized settings request")
|
133
137
|
@response.headers["WWW-Authenticate"] = 'Basic realm="Sensu Client Restricted Area"'
|
134
138
|
send_response(401, "Unauthorized", {
|
135
139
|
:response => "You must be authenticated using your http_options user and password settings"
|
@@ -137,8 +141,11 @@ module Sensu
|
|
137
141
|
end
|
138
142
|
end
|
139
143
|
|
140
|
-
def http_request_errback(
|
141
|
-
@logger.error("
|
144
|
+
def http_request_errback(error)
|
145
|
+
@logger.error("http socket error while processing request", {
|
146
|
+
:error => error.to_s,
|
147
|
+
:backtrace => error.backtrace
|
148
|
+
})
|
142
149
|
@response = EM::DelegatedHttpResponse.new(self)
|
143
150
|
@response.content_type "application/json"
|
144
151
|
send_response(500, "Internal Server Error", {
|
@@ -148,25 +155,37 @@ module Sensu
|
|
148
155
|
|
149
156
|
# This method is called to process HTTP requests
|
150
157
|
def process_http_request
|
151
|
-
@logger.debug("processing
|
158
|
+
@logger.debug("http socket processing", {
|
159
|
+
:http_request_method => @http_request_method,
|
160
|
+
:http_request_uri => @http_request_uri
|
161
|
+
})
|
152
162
|
@response = EM::DelegatedHttpResponse.new(self)
|
153
163
|
@response.content_type "application/json"
|
154
164
|
endpoint = @endpoints[@http_request_uri]
|
155
165
|
if endpoint
|
156
|
-
@logger.debug("endpoint
|
166
|
+
@logger.debug("http socket endpoint found", {
|
167
|
+
:http_request_uri => @http_request_uri,
|
168
|
+
:accepted_methods => endpoint["methods"].keys
|
169
|
+
})
|
157
170
|
method_name = @http_request_method.upcase
|
158
171
|
method_handler = endpoint["methods"][method_name]
|
159
172
|
if method_handler
|
160
|
-
@logger.debug("
|
173
|
+
@logger.debug("http socket executing handler", {
|
174
|
+
:method_name => method_name,
|
175
|
+
:http_request_uri => @http_request_uri
|
176
|
+
})
|
161
177
|
method_handler.call
|
162
178
|
else
|
163
|
-
@logger.debug("method
|
179
|
+
@logger.debug("http socket method is not allowed for endpoint", {
|
180
|
+
:method_name => method_name,
|
181
|
+
:http_request_uri => @http_request_uri
|
182
|
+
})
|
164
183
|
send_response(405, "Method Not Allowed", {
|
165
184
|
:response => "Valid methods for this endpoint: #{reqdef['methods'].keys}"
|
166
185
|
})
|
167
186
|
end
|
168
187
|
else
|
169
|
-
@logger.warn("unknown endpoint requested:
|
188
|
+
@logger.warn("http socket unknown endpoint requested", :http_request_uri => @http_request_uri)
|
170
189
|
help_response = {
|
171
190
|
:endpoints => {}
|
172
191
|
}
|
data/lib/sensu/client/process.rb
CHANGED
@@ -348,7 +348,7 @@ module Sensu
|
|
348
348
|
schedule_checks(standard_checks + extension_checks)
|
349
349
|
end
|
350
350
|
|
351
|
-
# Setup the Sensu client socket, for external check result
|
351
|
+
# Setup the Sensu client JSON socket, for external check result
|
352
352
|
# input. By default, the client socket is bound to localhost on
|
353
353
|
# TCP & UDP port 3030. The socket can be configured via the
|
354
354
|
# client definition, `:socket` with `:bind` and `:port`. The
|
@@ -357,7 +357,7 @@ module Sensu
|
|
357
357
|
# TCP socket server signature (Fixnum) and UDP connection object
|
358
358
|
# are stored in `@sockets`, so that they can be managed
|
359
359
|
# elsewhere, eg. `close_sockets()`.
|
360
|
-
def
|
360
|
+
def setup_json_socket
|
361
361
|
options = @settings[:client][:socket] || Hash.new
|
362
362
|
options[:bind] ||= "127.0.0.1"
|
363
363
|
options[:port] ||= 3030
|
@@ -373,18 +373,39 @@ module Sensu
|
|
373
373
|
socket.transport = @transport
|
374
374
|
socket.protocol = :udp
|
375
375
|
end
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
376
|
+
end
|
377
|
+
|
378
|
+
# Setup the Sensu client HTTP socket, for external check result
|
379
|
+
# input and informational queries. By default, the client HTTP
|
380
|
+
# socket is bound to localhost on TCP port 3031. The socket can
|
381
|
+
# be configured via the client definition, `:http_socket` with
|
382
|
+
# `:bind` and `:port`. Users can opt-out of using the HTTP
|
383
|
+
# socket by setting `:enabled` to `false. The current instance
|
384
|
+
# of the Sensu logger, settings, and transport are passed to the
|
385
|
+
# HTTP socket handler, `Sensu::Client::HTTPSocket`. The HTTP
|
386
|
+
# socket server signature (Fixnum) is stored in `@sockets`, so
|
387
|
+
# that it can be managed elsewhere, eg. `close_sockets()`.
|
388
|
+
def setup_http_socket
|
389
|
+
options = @settings[:client][:http_socket] || Hash.new
|
390
|
+
options[:bind] ||= "127.0.0.1"
|
391
|
+
options[:port] ||= 3031
|
392
|
+
unless options[:enabled] == false
|
393
|
+
@logger.debug("binding client http socket", :options => options)
|
394
|
+
@sockets << EM::start_server(options[:bind], options[:port], HTTPSocket) do |socket|
|
395
|
+
socket.logger = @logger
|
396
|
+
socket.settings = @settings
|
397
|
+
socket.transport = @transport
|
398
|
+
end
|
385
399
|
end
|
386
400
|
end
|
387
401
|
|
402
|
+
# Setup the Sensu client sockets, JSON TCP & UDP, and HTTP.
|
403
|
+
# Users can opt-out of using the HTTP socket via configuration.
|
404
|
+
def setup_sockets
|
405
|
+
setup_json_socket
|
406
|
+
setup_http_socket
|
407
|
+
end
|
408
|
+
|
388
409
|
# Call a callback (Ruby block) when there are no longer check
|
389
410
|
# executions in progress. This method is used when stopping the
|
390
411
|
# Sensu client. The `retry_until_true` helper method is used to
|
@@ -409,11 +430,10 @@ module Sensu
|
|
409
430
|
# default, the deregistration check result sets the `:handler` to
|
410
431
|
# `deregistration`. If the client provides its own `:deregistration`
|
411
432
|
# configuration, it's deep merged with the defaults. The
|
412
|
-
# check `:name`, `:output`, `:
|
413
|
-
#
|
414
|
-
# an invalid definition.
|
433
|
+
# check `:name`, `:output`, `:issued`, and `:executed` values
|
434
|
+
# are always overridden to guard against an invalid definition.
|
415
435
|
def deregister
|
416
|
-
check = {:handler => "deregistration", :
|
436
|
+
check = {:handler => "deregistration", :status => 1}
|
417
437
|
if @settings[:client].has_key?(:deregistration)
|
418
438
|
check = deep_merge(check, @settings[:client][:deregistration])
|
419
439
|
end
|
@@ -421,7 +441,6 @@ module Sensu
|
|
421
441
|
overrides = {
|
422
442
|
:name => "deregistration",
|
423
443
|
:output => "client initiated deregistration",
|
424
|
-
:status => 1,
|
425
444
|
:issued => timestamp,
|
426
445
|
:executed => timestamp
|
427
446
|
}
|
data/lib/sensu/constants.rb
CHANGED
data/lib/sensu/daemon.rb
CHANGED
data/lib/sensu/server/process.rb
CHANGED
@@ -71,11 +71,11 @@ module Sensu
|
|
71
71
|
# default, the registration check definition sets the `:handler`
|
72
72
|
# to `registration`. If the client provides its own
|
73
73
|
# `:registration` configuration, it's deep merged with the
|
74
|
-
# defaults. The check `:name`, `:output`, `:
|
75
|
-
#
|
76
|
-
#
|
74
|
+
# defaults. The check `:name`, `:output`, `:issued`, and
|
75
|
+
# `:executed` values are always overridden to guard against an
|
76
|
+
# invalid definition.
|
77
77
|
def create_registration_check(client)
|
78
|
-
check = {:handler => "registration"}
|
78
|
+
check = {:handler => "registration", :status => 1}
|
79
79
|
if client.has_key?(:registration)
|
80
80
|
check = deep_merge(check, client[:registration])
|
81
81
|
end
|
@@ -83,7 +83,6 @@ module Sensu
|
|
83
83
|
overrides = {
|
84
84
|
:name => "registration",
|
85
85
|
:output => "new client registration",
|
86
|
-
:status => 1,
|
87
86
|
:issued => timestamp,
|
88
87
|
:executed => timestamp
|
89
88
|
}
|
@@ -319,7 +318,16 @@ module Sensu
|
|
319
318
|
def truncate_check_output(check)
|
320
319
|
case check[:type]
|
321
320
|
when METRIC_CHECK_TYPE
|
322
|
-
|
321
|
+
begin
|
322
|
+
output_lines = check[:output].split("\n")
|
323
|
+
rescue ArgumentError
|
324
|
+
utf8_output = check[:output].encode("UTF-8", "binary", {
|
325
|
+
:invalid => :replace,
|
326
|
+
:undef => :replace,
|
327
|
+
:replace => ""
|
328
|
+
})
|
329
|
+
output_lines = utf8_output.split("\n")
|
330
|
+
end
|
323
331
|
output = output_lines.first || check[:output]
|
324
332
|
if output_lines.length > 1 || output.length > 255
|
325
333
|
output = output[0..255] + "\n..."
|
@@ -961,7 +969,7 @@ module Sensu
|
|
961
969
|
unless event_exists
|
962
970
|
check[:output] = "Last check execution was "
|
963
971
|
check[:output] << "#{time_since_last_execution} seconds ago"
|
964
|
-
check[:status] = 1
|
972
|
+
check[:status] = check[:ttl_status] || 1
|
965
973
|
publish_check_result(client_name, check)
|
966
974
|
end
|
967
975
|
end
|
data/sensu.gemspec
CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.add_dependency "eventmachine", "1.2.1"
|
16
16
|
s.add_dependency "sensu-json", "2.0.1"
|
17
17
|
s.add_dependency "sensu-logger", "1.2.1"
|
18
|
-
s.add_dependency "sensu-settings", "9.
|
18
|
+
s.add_dependency "sensu-settings", "9.6.0"
|
19
19
|
s.add_dependency "sensu-extension", "1.5.1"
|
20
20
|
s.add_dependency "sensu-extensions", "1.7.1"
|
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: 0.27.0.
|
4
|
+
version: 0.27.0.beta.1
|
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: 2016-11-
|
12
|
+
date: 2016-11-23 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: 9.
|
62
|
+
version: 9.6.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: 9.
|
69
|
+
version: 9.6.0
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: sensu-extension
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|