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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8bf59c803593f41d305fffed764fde70f2bf16ff
4
- data.tar.gz: e3e379506398d57ca6c8ab521648820e1d2519e4
3
+ metadata.gz: b5c247703a4d859125efdd51491b63191c0843f5
4
+ data.tar.gz: 5a1d36dced8609f6367f545a25f5f13a7ef72897
5
5
  SHA512:
6
- metadata.gz: b2dfc24bc617d45c3bab75292b7133d7f6fa29c39c8b33660cff06fd2826313e5f8d103beb7a0f158f675275f92892af2ea499f76dc1a2523ca8439641f97d8e
7
- data.tar.gz: 77d2b239f8e63026edb5c7973328df88a1f31a4adbd2d05a4b712ff9131a9e484ccf0b0a549e9ea8bfea943db2d5d7e498cb7f94b278f56d54e5eaf057311943
6
+ metadata.gz: 7c0b0f03f37285547e99c7560d21ee0df1bdb3bd43dd2000633820d6d8e423bded97979705bcd4f5e6ee78d6e6c7f3aefeae62a1a5bacec08e1a0604d8666260
7
+ data.tar.gz: ca62df0d37592701df2e2185d8bf4f9450dfc0a12d91c936488ca8a3a3d55d9f30ca6bff6b7f2e124a54cafbf305f50f8fc48d52762fc23a048a97ca3ada6f06
@@ -4,6 +4,7 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  gem 'rerun', git: 'https://github.com/alexch/rerun.git', branch: 'master'
7
+ gem 'ditty', path: '../ditty'
7
8
  gem 'sqlite3'
8
9
  gem 'simplecov'
9
10
  gem 'pry-byebug'
@@ -2,6 +2,8 @@
2
2
 
3
3
  require 'ditty/controllers/component'
4
4
  require 'proxes/models/permission'
5
+ require 'ditty/policies/user_policy'
6
+ require 'ditty/policies/role_policy'
5
7
  require 'proxes/policies/permission_policy'
6
8
 
7
9
  module ProxES
@@ -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
- node_stats = client.nodes.stats metric: 'os,fs,jvm'
27
+ node_stats = client.nodes.stats metric: 'os,fs,jvm'
31
28
 
32
- jvm_values = []
33
- jvm_passed = true
34
- node_stats['nodes'].each do |name, node|
35
- jvm_values << "#{name}: #{node['jvm']['mem']['heap_used_percent']}%"
36
- jvm_passed = false if node['jvm']['mem']['heap_used_percent'] > 85
37
- end
38
- checks << { text: 'Node JVM Heap', passed: jvm_passed, value: jvm_values }
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
- fs_values = []
41
- fs_passed = true
42
- node_stats['nodes'].each do |name, node|
43
- stats = node['fs']['total']
44
- left = stats['available_in_bytes'] / stats['total_in_bytes'].to_f * 100
45
- fs_values << "#{name}: #{'%.02f' % left}% Free"
46
- fs_passed = false if left < 10
47
- end
48
- checks << { text: 'Node File Systems', passed: fs_passed, value: fs_values }
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
- cpu_values = []
51
- cpu_passed = true
52
- node_stats['nodes'].each do |name, node|
53
- cpu_values << "#{name}: #{node['os']['cpu']['percent']}"
54
- cpu_passed = false if node['os']['cpu']['percent'].to_i > 70
55
- end
56
- checks << { text: 'Node CPU Usage', passed: cpu_passed, value: cpu_values }
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
- memory_values = []
59
- memory_passed = true
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 }
@@ -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
- full_path = source.fullpath == '' ? URI.parse(env['REQUEST_URI']).request_uri : source.fullpath
43
- target = Net::HTTP.const_get(source.request_method.capitalize).new(full_path)
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
 
@@ -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 REGEX
15
+ body.read.scan(REGEX).tap { |_r| body.rewind }
19
16
  end.map { |e| e[1] }.uniq
20
17
  end
21
18
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ProxES
4
- VERSION = '0.8.3'.freeze
4
+ VERSION = '0.8.4'.freeze
5
5
  end
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.3
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-05 00:00:00.000000000 Z
11
+ date: 2017-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler