riemann-tools 1.8.2 → 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +2 -2
- data/.github/workflows/codeql-analysis.yml +1 -1
- data/CHANGELOG.md +18 -1
- data/lib/riemann/tools/bench.rb +1 -1
- data/lib/riemann/tools/haproxy.rb +5 -1
- data/lib/riemann/tools/http_check.rb +52 -3
- data/lib/riemann/tools/net.rb +1 -1
- data/lib/riemann/tools/riemann_client_wrapper.rb +15 -1
- data/lib/riemann/tools/version.rb +1 -1
- data/lib/riemann/tools.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a687b20923e917950674963afc61f94986d17067dbaa847b882898b9efd213b
|
4
|
+
data.tar.gz: 3ecceb218ec5603f4b15a8aae99ddca0578377eb45c6e22877e61e78f07a3eee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d7e1dda53482e7725ab3fe23d49488db45dfbf69bcf2e33550d385ae1fb79f4d868be1685c225b46180bd6f00d9c1ce723959d02e739570d0c021bdd9cf84e8
|
7
|
+
data.tar.gz: e99bb824d6d3a17d9f2ea47bbf31bf468ce3f567949ae632db2927c4e8922a8d6f6b3141bda0f11da624493bfc7fe982749a5bae971a40572e134bff9e839b6f
|
data/.github/workflows/ci.yml
CHANGED
@@ -13,7 +13,7 @@ jobs:
|
|
13
13
|
lint:
|
14
14
|
runs-on: ubuntu-latest
|
15
15
|
steps:
|
16
|
-
- uses: actions/checkout@
|
16
|
+
- uses: actions/checkout@v4
|
17
17
|
- name: Setup ruby
|
18
18
|
uses: ruby/setup-ruby@v1
|
19
19
|
with:
|
@@ -33,7 +33,7 @@ jobs:
|
|
33
33
|
- 3.1
|
34
34
|
- 3.2
|
35
35
|
steps:
|
36
|
-
- uses: actions/checkout@
|
36
|
+
- uses: actions/checkout@v4
|
37
37
|
- name: Setup Ruby
|
38
38
|
uses: ruby/setup-ruby@v1
|
39
39
|
with:
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [v1.9.0](https://github.com/riemann/riemann-tools/tree/v1.9.0) (2023-12-08)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/riemann/riemann-tools/compare/v1.8.2...v1.9.0)
|
6
|
+
|
7
|
+
**Implemented enhancements:**
|
8
|
+
|
9
|
+
- Use truncated exponential backoff for reconnection [\#272](https://github.com/riemann/riemann-tools/pull/272) ([smortex](https://github.com/smortex))
|
10
|
+
- Add redirect support to `riemann-http-check` [\#270](https://github.com/riemann/riemann-tools/pull/270) ([smortex](https://github.com/smortex))
|
11
|
+
|
12
|
+
**Fixed bugs:**
|
13
|
+
|
14
|
+
- Fix `riemann-haproxy` with Ruby 3.0+ [\#273](https://github.com/riemann/riemann-tools/pull/273) ([smortex](https://github.com/smortex))
|
15
|
+
|
16
|
+
**Merged pull requests:**
|
17
|
+
|
18
|
+
- Bump actions/checkout from 3 to 4 [\#271](https://github.com/riemann/riemann-tools/pull/271) ([dependabot[bot]](https://github.com/apps/dependabot))
|
19
|
+
|
3
20
|
## [v1.8.2](https://github.com/riemann/riemann-tools/tree/v1.8.2) (2023-05-22)
|
4
21
|
|
5
22
|
[Full Changelog](https://github.com/riemann/riemann-tools/compare/v1.8.1...v1.8.2)
|
@@ -95,7 +112,7 @@
|
|
95
112
|
|
96
113
|
**Implemented enhancements:**
|
97
114
|
|
98
|
-
- Add support for configuration file to riemann-wrapper [\#235](https://github.com/riemann/riemann-tools/pull/235) ([smortex](https://github.com/smortex))
|
115
|
+
- Add support for a configuration file to `riemann-wrapper` [\#235](https://github.com/riemann/riemann-tools/pull/235) ([smortex](https://github.com/smortex))
|
99
116
|
- Add `riemann-md` to monitor Linux RAID/md health [\#232](https://github.com/riemann/riemann-tools/pull/232) ([smortex](https://github.com/smortex))
|
100
117
|
- Add `riemann-zpool` to monitor zpool health [\#231](https://github.com/riemann/riemann-tools/pull/231) ([smortex](https://github.com/smortex))
|
101
118
|
|
data/lib/riemann/tools/bench.rb
CHANGED
@@ -15,7 +15,7 @@ module Riemann
|
|
15
15
|
@hosts = %w[a b c d e f g h i j]
|
16
16
|
@services = %w[test1 test2 test3 foo bar baz xyzzy attack cat treat]
|
17
17
|
@states = {}
|
18
|
-
@client = Riemann::Client.new(host:
|
18
|
+
@client = Riemann::Client.new(host: ARGV.first || 'localhost')
|
19
19
|
end
|
20
20
|
|
21
21
|
def evolve(state)
|
@@ -44,6 +44,10 @@ module Riemann
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def csv
|
47
|
+
CSV.parse(body.split('# ')[1], headers: true)
|
48
|
+
end
|
49
|
+
|
50
|
+
def body
|
47
51
|
http = ::Net::HTTP.new(@uri.host, @uri.port)
|
48
52
|
http.use_ssl = true if @uri.scheme == 'https'
|
49
53
|
res = http.start do |h|
|
@@ -53,8 +57,8 @@ module Riemann
|
|
53
57
|
get.basic_auth userinfo[0], userinfo[1]
|
54
58
|
end
|
55
59
|
h.request get
|
60
|
+
res.body
|
56
61
|
end
|
57
|
-
CSV.parse(res.body.split('# ')[1], { headers: true })
|
58
62
|
end
|
59
63
|
end
|
60
64
|
end
|
@@ -25,6 +25,8 @@ module Riemann
|
|
25
25
|
opt :connection_latency_critical, 'Lattency critical threshold', short: :none, default: 0.25
|
26
26
|
opt :response_latency_warning, 'Lattency warning threshold', short: :none, default: 0.5
|
27
27
|
opt :response_latency_critical, 'Lattency critical threshold', short: :none, default: 1.0
|
28
|
+
opt :follow_redirects, 'Follow redirects (301, 302)', short: :none, default: true
|
29
|
+
opt :max_redirects, 'Stop following redirects after this number of hops', short: :none, default: 5
|
28
30
|
opt :http_timeout, 'Timeout (in seconds) for HTTP requests', short: :none, default: 5.0
|
29
31
|
opt :checks, 'A list of checks to run.', short: :none, type: :strings, default: %w[consistency connection-latency response-code response-latency]
|
30
32
|
opt :resolvers, 'Run this number of resolver threads', short: :none, type: :integer, default: 5
|
@@ -100,8 +102,7 @@ module Riemann
|
|
100
102
|
end
|
101
103
|
|
102
104
|
def test_uri_addresses(uri, addresses)
|
103
|
-
request =
|
104
|
-
request.basic_auth(uri.user, uri.password)
|
105
|
+
request = get_request(uri)
|
105
106
|
|
106
107
|
responses = []
|
107
108
|
|
@@ -147,7 +148,15 @@ module Riemann
|
|
147
148
|
)
|
148
149
|
end
|
149
150
|
|
150
|
-
def
|
151
|
+
def get_request(uri)
|
152
|
+
request = ::Net::HTTP::Get.new(uri, { 'user-agent' => opts[:user_agent] })
|
153
|
+
|
154
|
+
request.basic_auth(uri.user, uri.password)
|
155
|
+
|
156
|
+
request
|
157
|
+
end
|
158
|
+
|
159
|
+
def test_uri_address(uri, address, request, redirect_count: 0)
|
151
160
|
response = nil
|
152
161
|
|
153
162
|
start = Time.now
|
@@ -173,12 +182,43 @@ module Riemann
|
|
173
182
|
report_http_endpoint_latency(http, uri, 'connection', start, connected) if opts[:checks].include?('connection-latency')
|
174
183
|
report_http_endpoint_latency(http, uri, 'response', start, done) if opts[:checks].include?('response-latency')
|
175
184
|
|
185
|
+
if opts[:follow_redirects] && %w[301 302].include?(response.code)
|
186
|
+
next_uri = redirect_uri(uri, response['Location'])
|
187
|
+
|
188
|
+
if same_origin?(uri, next_uri)
|
189
|
+
if redirect_count == opts[:max_redirects]
|
190
|
+
report_http_endpoint_max_redirects(http, uri)
|
191
|
+
return nil
|
192
|
+
else
|
193
|
+
response = test_uri_address(next_uri, address, get_request(next_uri), redirect_count: redirect_count + 1)
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
176
198
|
response
|
177
199
|
rescue StandardError
|
178
200
|
# Ignore this address
|
179
201
|
nil
|
180
202
|
end
|
181
203
|
|
204
|
+
def redirect_uri(uri, location)
|
205
|
+
res = URI.parse(location)
|
206
|
+
|
207
|
+
res.scheme ||= uri.scheme
|
208
|
+
res.host ||= uri.host
|
209
|
+
res.port ||= uri.port
|
210
|
+
res.user ||= res.user
|
211
|
+
res.password ||= res.password
|
212
|
+
|
213
|
+
res
|
214
|
+
end
|
215
|
+
|
216
|
+
def same_origin?(left, right)
|
217
|
+
left.scheme == right.scheme &&
|
218
|
+
left.host == right.host &&
|
219
|
+
left.port == right.port
|
220
|
+
end
|
221
|
+
|
182
222
|
def report_http_endpoint_response_code(http, uri, response)
|
183
223
|
return unless response
|
184
224
|
|
@@ -215,6 +255,15 @@ module Riemann
|
|
215
255
|
end
|
216
256
|
end
|
217
257
|
|
258
|
+
def report_http_endpoint_max_redirects(http, uri)
|
259
|
+
report(
|
260
|
+
{
|
261
|
+
state: 'critical',
|
262
|
+
description: "Reached the limit of #{opts[:max_redirects]} redirects",
|
263
|
+
}.merge(endpoint_report(http, uri, 'redirects')),
|
264
|
+
)
|
265
|
+
end
|
266
|
+
|
218
267
|
def latency_state(name, latency)
|
219
268
|
critical_threshold = opts["#{name}_latency_critical".to_sym]
|
220
269
|
warning_threshold = opts["#{name}_latency_warning".to_sym]
|
data/lib/riemann/tools/net.rb
CHANGED
@@ -108,7 +108,7 @@ module Riemann
|
|
108
108
|
|
109
109
|
if @old_state
|
110
110
|
# Report services from `@old_state` that don't exist in `state` as expired
|
111
|
-
@old_state.reject { |k| state.key?(k) }.
|
111
|
+
@old_state.reject { |k| state.key?(k) }.each_key do |service|
|
112
112
|
report(service: service.dup, state: 'expired')
|
113
113
|
end
|
114
114
|
|
@@ -9,6 +9,10 @@ module Riemann
|
|
9
9
|
class RiemannClientWrapper
|
10
10
|
attr_reader :options
|
11
11
|
|
12
|
+
BACKOFF_TMIN = 0.5 # Minimum delay between reconnection attempts
|
13
|
+
BACKOFF_TMAX = 30.0 # Maximum delay
|
14
|
+
BACKOFF_FACTOR = 2
|
15
|
+
|
12
16
|
def initialize(options)
|
13
17
|
@options = options
|
14
18
|
|
@@ -18,6 +22,8 @@ module Riemann
|
|
18
22
|
|
19
23
|
@worker = Thread.new do
|
20
24
|
Thread.current.abort_on_exception = true
|
25
|
+
backoff_delay = BACKOFF_TMIN
|
26
|
+
|
21
27
|
loop do
|
22
28
|
events = []
|
23
29
|
|
@@ -25,8 +31,16 @@ module Riemann
|
|
25
31
|
events << @queue.pop while !@queue.empty? && events.size < @max_bulk_size
|
26
32
|
|
27
33
|
client.bulk_send(events)
|
34
|
+
backoff_delay = BACKOFF_TMIN
|
28
35
|
rescue StandardError => e
|
29
|
-
|
36
|
+
sleep(backoff_delay)
|
37
|
+
|
38
|
+
dropped_count = events.size + @queue.size
|
39
|
+
@queue.clear
|
40
|
+
warn "Dropped #{dropped_count} event#{'s' if dropped_count > 1} due to #{e}"
|
41
|
+
|
42
|
+
backoff_delay *= BACKOFF_FACTOR
|
43
|
+
backoff_delay = BACKOFF_TMAX if backoff_delay > BACKOFF_TMAX
|
30
44
|
end
|
31
45
|
end
|
32
46
|
|
data/lib/riemann/tools.rb
CHANGED
@@ -63,7 +63,7 @@ module Riemann
|
|
63
63
|
event[:tags] = [*event.fetch(:tags, [])] + options[:tag].map(&:dup)
|
64
64
|
end
|
65
65
|
|
66
|
-
event[:ttl] ||=
|
66
|
+
event[:ttl] ||= options[:ttl] || (options[:interval] * 2)
|
67
67
|
|
68
68
|
event[:host] = options[:event_host].dup if options[:event_host]
|
69
69
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: riemann-tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kyle Kingsbury
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -367,7 +367,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
367
367
|
- !ruby/object:Gem::Version
|
368
368
|
version: '0'
|
369
369
|
requirements: []
|
370
|
-
rubygems_version: 3.4.
|
370
|
+
rubygems_version: 3.4.20
|
371
371
|
signing_key:
|
372
372
|
specification_version: 4
|
373
373
|
summary: Utilities which submit events to Riemann.
|