litmus_paper 1.3.0 → 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/README.md +5 -0
- data/lib/litmus_paper/metric/unix_socket_utilization.rb +35 -0
- data/lib/litmus_paper/version.rb +1 -1
- data/lib/litmus_paper.rb +1 -0
- data/litmus_paper.gemspec +1 -0
- data/spec/litmus_paper/metric/unix_socket_utilization_spec.rb +41 -0
- metadata +42 -25
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
NzNlMDI0OTAwMzk3MDQ3YjQyYmQ1ZDNjODMwZDZkMTRiYmRmZTQ5NA==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 81d5bca1668f1457cd9c766f4e5213ea2867921d
|
4
|
+
data.tar.gz: d6c0158e8d8895dcd00e8af89183900a022613f4
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
MjRmZTZlMzRjZDY1YTVkNTYxNjg1MDIzYzJjMWM4ZTRjYjJhYmUyYTZiNDdm
|
11
|
-
OTEwMGFlOWZlOGUyZjEyZjY4NmQ5NWZhMDBkOGQ1MDllMWFjMmI=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
MTJkYmU2NzU0NDY2MmJiZDVhNWMyNzUzZDQyYmUzN2MwYWRlZjRiMmJlMzdj
|
14
|
-
MWE1ZWY0NzU5MTcwM2VhMjJhY2I3MDVkM2QzNWJhYjZhMmVjMWZiZDBiYTU2
|
15
|
-
NzJhMmE0NmFiNGVmMGIzOTk3YzdmZDQwMzc2OTcxZTE2Y2Q5YmM=
|
6
|
+
metadata.gz: 843f555781fd9e5c2c9f28289322a18e44bfef87bcb680c563f86f3745e1bd943a84ef99d61e053339469821c8dfed2a433a229ff388b61d2bef2dab7202966c
|
7
|
+
data.tar.gz: 4fa41594e74cf755f2e5119a68861c47c3503b5bd2d0bd6c50280df6bbc2fbfaf7c89bdd3ac09eda09e7f1b47ba1f3868c7078d0f471da18baec45b0ba0e2359
|
data/README.md
CHANGED
@@ -176,6 +176,11 @@ Here are all the types of checks currently implemented:
|
|
176
176
|
* weight (0-100)
|
177
177
|
* timeout (defaults to 5s)
|
178
178
|
|
179
|
+
- `unix_socket_utilization` (`Metric::UnixSocketUtilitization`): Compares the number of active, queued requests against the maximum number of expected connections, [see](lib/litmus_paper/metric/unix_socket_utilization.rb) for the implementation of the algorithm.
|
180
|
+
* weight (0-100)
|
181
|
+
* socket_path (path on the filesystem where the socket is located)
|
182
|
+
* maxconn (maximum number of concurrent connection the server backing the socket is supposed to handle)
|
183
|
+
|
179
184
|
- `big_brother_service` (`Metric::BigBrotherService`): Used in conjunction with [Big Brother](https://github.com/braintree/big_brother), reports health based on the overall health of another load balanced service.
|
180
185
|
* service
|
181
186
|
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'raindrops'
|
2
|
+
|
3
|
+
module LitmusPaper
|
4
|
+
module Metric
|
5
|
+
class UnixSocketUtilitization
|
6
|
+
def initialize(weight, socket_path, maxconn)
|
7
|
+
@weight = weight
|
8
|
+
@socket_path = socket_path
|
9
|
+
@maxconn = maxconn
|
10
|
+
end
|
11
|
+
|
12
|
+
def current_health
|
13
|
+
stats = _stats
|
14
|
+
if stats.queued == 0
|
15
|
+
return @weight
|
16
|
+
else
|
17
|
+
return [
|
18
|
+
@weight - (
|
19
|
+
(@weight * _stats.active.to_f) / (3 * @maxconn.to_f) +
|
20
|
+
(2 * @weight * _stats.queued.to_f) / (3 * @maxconn.to_f)
|
21
|
+
), 1
|
22
|
+
].max
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def _stats
|
27
|
+
Raindrops::Linux.unix_listener_stats([@socket_path])[@socket_path]
|
28
|
+
end
|
29
|
+
|
30
|
+
def to_s
|
31
|
+
"Metric::UnixSocketUtilitization(weight: #{@weight}, maxconn: #{@maxconn}, path: #{@socket_path})"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/litmus_paper/version.rb
CHANGED
data/lib/litmus_paper.rb
CHANGED
@@ -31,6 +31,7 @@ require 'litmus_paper/metric/cpu_load'
|
|
31
31
|
require 'litmus_paper/metric/haproxy_backends_health'
|
32
32
|
require 'litmus_paper/metric/internet_health'
|
33
33
|
require 'litmus_paper/metric/script'
|
34
|
+
require 'litmus_paper/metric/unix_socket_utilization'
|
34
35
|
require 'litmus_paper/service'
|
35
36
|
require 'litmus_paper/status_file'
|
36
37
|
require 'litmus_paper/util'
|
data/litmus_paper.gemspec
CHANGED
@@ -20,6 +20,7 @@ Gem::Specification.new do |gem|
|
|
20
20
|
gem.add_dependency "remote_syslog_logger", "~> 1.0.3"
|
21
21
|
gem.add_dependency "unicorn", "~> 4.6.2"
|
22
22
|
gem.add_dependency "colorize"
|
23
|
+
gem.add_dependency "raindrops", "~> 0.19.0"
|
23
24
|
|
24
25
|
gem.add_development_dependency "rspec", "~> 2.9.0"
|
25
26
|
gem.add_development_dependency "rack-test", "~> 0.6.1"
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe LitmusPaper::Metric::UnixSocketUtilitization do
|
4
|
+
describe "#current_health" do
|
5
|
+
it "returns supplied weight when there is no queued request" do
|
6
|
+
LitmusPaper::Metric::UnixSocketUtilitization.any_instance.stub(
|
7
|
+
:_stats => OpenStruct.new({:queued => 0, :active => 10}),
|
8
|
+
)
|
9
|
+
health = LitmusPaper::Metric::UnixSocketUtilitization.new(
|
10
|
+
100,
|
11
|
+
'/var/run/foo.sock',
|
12
|
+
10
|
13
|
+
).current_health
|
14
|
+
health.should == 100
|
15
|
+
end
|
16
|
+
|
17
|
+
it "adjusts weight based on queued requests" do
|
18
|
+
LitmusPaper::Metric::UnixSocketUtilitization.any_instance.stub(
|
19
|
+
:_stats => OpenStruct.new({:queued => 7, :active => 10}),
|
20
|
+
)
|
21
|
+
health = LitmusPaper::Metric::UnixSocketUtilitization.new(
|
22
|
+
100,
|
23
|
+
'/var/run/foo.sock',
|
24
|
+
10
|
25
|
+
).current_health
|
26
|
+
health.to_i.should == 20
|
27
|
+
end
|
28
|
+
|
29
|
+
it "sets weight to 1 when queued requests is more than maxconn" do
|
30
|
+
LitmusPaper::Metric::UnixSocketUtilitization.any_instance.stub(
|
31
|
+
:_stats => OpenStruct.new({:queued => 11, :active => 10}),
|
32
|
+
)
|
33
|
+
health = LitmusPaper::Metric::UnixSocketUtilitization.new(
|
34
|
+
100,
|
35
|
+
'/var/run/foo.sock',
|
36
|
+
10
|
37
|
+
).current_health
|
38
|
+
health.should == 1
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
metadata
CHANGED
@@ -1,125 +1,139 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: litmus_paper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Braintreeps
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 1.3.2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 1.3.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: remote_syslog_logger
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 1.0.3
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 1.0.3
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: unicorn
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 4.6.2
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 4.6.2
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: colorize
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: raindrops
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.19.0
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.19.0
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: rspec
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
|
-
- - ~>
|
87
|
+
- - "~>"
|
74
88
|
- !ruby/object:Gem::Version
|
75
89
|
version: 2.9.0
|
76
90
|
type: :development
|
77
91
|
prerelease: false
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
80
|
-
- - ~>
|
94
|
+
- - "~>"
|
81
95
|
- !ruby/object:Gem::Version
|
82
96
|
version: 2.9.0
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: rack-test
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
86
100
|
requirements:
|
87
|
-
- - ~>
|
101
|
+
- - "~>"
|
88
102
|
- !ruby/object:Gem::Version
|
89
103
|
version: 0.6.1
|
90
104
|
type: :development
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
|
-
- - ~>
|
108
|
+
- - "~>"
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: 0.6.1
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: rake
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
100
114
|
requirements:
|
101
|
-
- - ~>
|
115
|
+
- - "~>"
|
102
116
|
- !ruby/object:Gem::Version
|
103
117
|
version: 0.9.2.2
|
104
118
|
type: :development
|
105
119
|
prerelease: false
|
106
120
|
version_requirements: !ruby/object:Gem::Requirement
|
107
121
|
requirements:
|
108
|
-
- - ~>
|
122
|
+
- - "~>"
|
109
123
|
- !ruby/object:Gem::Version
|
110
124
|
version: 0.9.2.2
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
126
|
name: rake_commit
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
114
128
|
requirements:
|
115
|
-
- - ~>
|
129
|
+
- - "~>"
|
116
130
|
- !ruby/object:Gem::Version
|
117
131
|
version: '0.13'
|
118
132
|
type: :development
|
119
133
|
prerelease: false
|
120
134
|
version_requirements: !ruby/object:Gem::Requirement
|
121
135
|
requirements:
|
122
|
-
- - ~>
|
136
|
+
- - "~>"
|
123
137
|
- !ruby/object:Gem::Version
|
124
138
|
version: '0.13'
|
125
139
|
description: Backend health tester for HA Services
|
@@ -132,10 +146,10 @@ executables:
|
|
132
146
|
extensions: []
|
133
147
|
extra_rdoc_files: []
|
134
148
|
files:
|
135
|
-
- .gitignore
|
136
|
-
- .rake_commit
|
137
|
-
- .ruby-version
|
138
|
-
- .travis.yml
|
149
|
+
- ".gitignore"
|
150
|
+
- ".rake_commit"
|
151
|
+
- ".ruby-version"
|
152
|
+
- ".travis.yml"
|
139
153
|
- Dockerfile
|
140
154
|
- Gemfile
|
141
155
|
- LICENSE
|
@@ -175,6 +189,7 @@ files:
|
|
175
189
|
- lib/litmus_paper/metric/haproxy_backends_health.rb
|
176
190
|
- lib/litmus_paper/metric/internet_health.rb
|
177
191
|
- lib/litmus_paper/metric/script.rb
|
192
|
+
- lib/litmus_paper/metric/unix_socket_utilization.rb
|
178
193
|
- lib/litmus_paper/service.rb
|
179
194
|
- lib/litmus_paper/status_file.rb
|
180
195
|
- lib/litmus_paper/terminal_output.rb
|
@@ -201,6 +216,7 @@ files:
|
|
201
216
|
- spec/litmus_paper/metric/haproxy_backends_health_spec.rb
|
202
217
|
- spec/litmus_paper/metric/internet_health_spec.rb
|
203
218
|
- spec/litmus_paper/metric/script_spec.rb
|
219
|
+
- spec/litmus_paper/metric/unix_socket_utilization_spec.rb
|
204
220
|
- spec/litmus_paper/service_spec.rb
|
205
221
|
- spec/litmus_paper/status_file_spec.rb
|
206
222
|
- spec/litmus_paper_spec.rb
|
@@ -237,17 +253,17 @@ require_paths:
|
|
237
253
|
- lib
|
238
254
|
required_ruby_version: !ruby/object:Gem::Requirement
|
239
255
|
requirements:
|
240
|
-
- -
|
256
|
+
- - ">="
|
241
257
|
- !ruby/object:Gem::Version
|
242
258
|
version: '0'
|
243
259
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
244
260
|
requirements:
|
245
|
-
- -
|
261
|
+
- - ">="
|
246
262
|
- !ruby/object:Gem::Version
|
247
263
|
version: '0'
|
248
264
|
requirements: []
|
249
265
|
rubyforge_project:
|
250
|
-
rubygems_version: 2.
|
266
|
+
rubygems_version: 2.5.2.1
|
251
267
|
signing_key:
|
252
268
|
specification_version: 4
|
253
269
|
summary: Backend health tester for HA Services, partner project of big_brother
|
@@ -270,6 +286,7 @@ test_files:
|
|
270
286
|
- spec/litmus_paper/metric/haproxy_backends_health_spec.rb
|
271
287
|
- spec/litmus_paper/metric/internet_health_spec.rb
|
272
288
|
- spec/litmus_paper/metric/script_spec.rb
|
289
|
+
- spec/litmus_paper/metric/unix_socket_utilization_spec.rb
|
273
290
|
- spec/litmus_paper/service_spec.rb
|
274
291
|
- spec/litmus_paper/status_file_spec.rb
|
275
292
|
- spec/litmus_paper_spec.rb
|