proxes 0.8.3 → 0.8.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.dev +1 -0
- data/lib/proxes/controllers/permissions.rb +2 -0
- data/lib/proxes/controllers/status.rb +34 -33
- data/lib/proxes/forwarder.rb +4 -11
- data/lib/proxes/policies/request/bulk_policy.rb +2 -1
- data/lib/proxes/request/bulk.rb +1 -4
- data/lib/proxes/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5c247703a4d859125efdd51491b63191c0843f5
|
4
|
+
data.tar.gz: 5a1d36dced8609f6367f545a25f5f13a7ef72897
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c0b0f03f37285547e99c7560d21ee0df1bdb3bd43dd2000633820d6d8e423bded97979705bcd4f5e6ee78d6e6c7f3aefeae62a1a5bacec08e1a0604d8666260
|
7
|
+
data.tar.gz: ca62df0d37592701df2e2185d8bf4f9450dfc0a12d91c936488ca8a3a3d55d9f30ca6bff6b7f2e124a54cafbf305f50f8fc48d52762fc23a048a97ca3ada6f06
|
data/Gemfile.dev
CHANGED
@@ -23,45 +23,46 @@ module ProxES
|
|
23
23
|
health = cluster_health
|
24
24
|
checks << { text: 'Cluster Reachable', passed: true, value: health['cluster_name'] }
|
25
25
|
checks << { text: 'Cluster Health', passed: health['status'] == 'green', value: health['status'] }
|
26
|
-
rescue StandardError
|
27
|
-
checks << { text: 'Cluster Reachable', passed: false}
|
28
|
-
end
|
29
26
|
|
30
|
-
|
27
|
+
node_stats = client.nodes.stats metric: 'os,fs,jvm'
|
31
28
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
29
|
+
jvm_values = []
|
30
|
+
jvm_passed = true
|
31
|
+
node_stats['nodes'].each do |name, node|
|
32
|
+
jvm_values << "#{name}: #{node['jvm']['mem']['heap_used_percent']}%"
|
33
|
+
jvm_passed = false if node['jvm']['mem']['heap_used_percent'] > 85
|
34
|
+
end
|
35
|
+
checks << { text: 'Node JVM Heap', passed: jvm_passed, value: jvm_values }
|
39
36
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
37
|
+
fs_values = []
|
38
|
+
fs_passed = true
|
39
|
+
node_stats['nodes'].each do |name, node|
|
40
|
+
stats = node['fs']['total']
|
41
|
+
left = stats['available_in_bytes'] / stats['total_in_bytes'].to_f * 100
|
42
|
+
fs_values << "#{name}: #{'%.02f' % left}% Free"
|
43
|
+
fs_passed = false if left < 10
|
44
|
+
end
|
45
|
+
checks << { text: 'Node File Systems', passed: fs_passed, value: fs_values }
|
49
46
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
47
|
+
cpu_values = []
|
48
|
+
cpu_passed = true
|
49
|
+
node_stats['nodes'].each do |name, node|
|
50
|
+
cpu_values << "#{name}: #{node['os']['cpu']['percent']}"
|
51
|
+
cpu_passed = false if node['os']['cpu']['percent'].to_i > 70
|
52
|
+
end
|
53
|
+
checks << { text: 'Node CPU Usage', passed: cpu_passed, value: cpu_values }
|
54
|
+
|
55
|
+
memory_values = []
|
56
|
+
memory_passed = true
|
57
|
+
node_stats['nodes'].each do |name, node|
|
58
|
+
memory_values << "#{name}: #{node['os']['mem']['used_percent']}"
|
59
|
+
memory_passed = false if node['os']['mem']['used_percent'].to_i >= 100
|
60
|
+
end
|
61
|
+
checks << { text: 'Node Memory Usage', passed: memory_passed, value: memory_values }
|
57
62
|
|
58
|
-
|
59
|
-
|
60
|
-
node_stats['nodes'].each do |name, node|
|
61
|
-
memory_values << "#{name}: #{node['os']['mem']['used_percent']}"
|
62
|
-
memory_passed = false if node['os']['mem']['used_percent'].to_i >= 100
|
63
|
+
rescue StandardError
|
64
|
+
checks << { text: 'Cluster Reachable', passed: false}
|
63
65
|
end
|
64
|
-
checks << { text: 'Node Memory Usage', passed: memory_passed, value: memory_values }
|
65
66
|
|
66
67
|
status checks.find { |c| c[:passed] == false } ? 500 : 200
|
67
68
|
haml :'status/check', locals: { title: 'Status Check', checks: checks }
|
data/lib/proxes/forwarder.rb
CHANGED
@@ -11,15 +11,8 @@ module ProxES
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def call(env)
|
14
|
-
|
15
14
|
http = Net::HTTP.new(backend.host, backend.port)
|
16
|
-
if backend.is_a? URI::HTTPS
|
17
|
-
store = OpenSSL::X509::Store.new
|
18
|
-
store.set_default_paths
|
19
|
-
http.use_ssl = true
|
20
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
21
|
-
http.cert_store = store
|
22
|
-
end
|
15
|
+
http.use_ssl = true if backend.is_a? URI::HTTPS
|
23
16
|
request = request_from(env)
|
24
17
|
request.basic_auth backend.user, backend.password
|
25
18
|
response = http.request(request)
|
@@ -39,8 +32,8 @@ module ProxES
|
|
39
32
|
|
40
33
|
def request_from(env)
|
41
34
|
source = Rack::Request.new(env)
|
42
|
-
|
43
|
-
target = Net::HTTP.const_get(source.request_method.capitalize).new(
|
35
|
+
fullpath = source.fullpath == '' ? URI.parse(env['REQUEST_URI']).request_uri : source.fullpath
|
36
|
+
target = Net::HTTP.const_get(source.request_method.capitalize).new(fullpath)
|
44
37
|
|
45
38
|
body = body_from(source)
|
46
39
|
if body
|
@@ -53,7 +46,7 @@ module ProxES
|
|
53
46
|
|
54
47
|
def body_from(request)
|
55
48
|
return nil if request.body.nil? || (Kernel.const_defined?('::Puma::NullIO') && request.body.is_a?(Puma::NullIO))
|
56
|
-
request.body.read
|
49
|
+
request.body.read.tap { |_r| request.body.rewind }
|
57
50
|
end
|
58
51
|
|
59
52
|
class << self
|
@@ -13,9 +13,10 @@ module ProxES
|
|
13
13
|
end
|
14
14
|
|
15
15
|
return false if request.index && !index_allowed?
|
16
|
+
return false if request.bulk_indices == '' || patterns.empty?
|
16
17
|
|
17
18
|
patterns.find do |pattern|
|
18
|
-
request.bulk_indices.find { |idx| idx !~ /#{pattern}/}
|
19
|
+
request.bulk_indices.find { |idx| idx !~ /#{pattern}/ }
|
19
20
|
end.nil?
|
20
21
|
end
|
21
22
|
|
data/lib/proxes/request/bulk.rb
CHANGED
@@ -10,12 +10,9 @@ module ProxES
|
|
10
10
|
|
11
11
|
REGEX = /"(index|delete|create|update)".*"_index"\s*:\s*"(.*?)"/
|
12
12
|
|
13
|
-
def bulk_actions
|
14
|
-
end
|
15
|
-
|
16
13
|
def bulk_indices
|
17
14
|
@bulk_indices ||= begin
|
18
|
-
body.read.scan
|
15
|
+
body.read.scan(REGEX).tap { |_r| body.rewind }
|
19
16
|
end.map { |e| e[1] }.uniq
|
20
17
|
end
|
21
18
|
|
data/lib/proxes/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: proxes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jurgens du Toit
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|