Skip to content

Commit 5f29d35

Browse files
committed
fix: Correctly reference status check sources
1 parent 9e0640b commit 5f29d35

File tree

8 files changed

+12
-12
lines changed

8 files changed

+12
-12
lines changed

lib/proxes/controllers/status.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Status < Ditty::ApplicationController
3434
checks.unshift(
3535
text: 'Cluster Reachable',
3636
passed: true,
37-
value: ProxES::StatusCheck.source_result('health')['cluster_name']['cluster_name']
37+
value: ProxES::StatusCheck.source_result['health']['cluster_name']['cluster_name']
3838
)
3939
rescue Faraday::Error => e
4040
checks << { text: 'Cluster Reachable', passed: false, value: e.message }

lib/proxes/models/status_check.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def passed?
3131
end
3232

3333
def source_result
34-
self.class.source_result(source)
34+
self.class.source_result[source]
3535
end
3636

3737
def children; end
@@ -53,12 +53,12 @@ def es_client
5353
@@es_client
5454
end
5555

56-
def source_result(source)
56+
def source_result
5757
raise 'No search client' unless es_client
5858

59-
@source_result ||= TimedCache.new do |h, k|
59+
@@source_result ||= TimedCache.new do |h, k|
6060
h[k] = es_client
61-
SOURCE_CALLS[source.to_sym].each do |call|
61+
SOURCE_CALLS[k.to_sym].each do |call|
6262
h[k] = h[k].send(call)
6363
end
6464
h[k]

lib/proxes/models/status_checks/cluster_health_status_check.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
module ProxES
44
class ClusterHealthStatusCheck < StatusCheck
55
def value
6-
source_result['status']['status']
6+
source_result['status']
77
end
88

99
def check

lib/proxes/models/status_checks/cpu_status_check.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def value
77
end
88

99
def children
10-
@children ||= source_result['nodes']['nodes'].values.map do |node|
10+
@children ||= source_result['nodes'].values.map do |node|
1111
value = node['os']['cpu_percent'] || node['os']['cpu']['percent']
1212
[
1313
node['name'],

lib/proxes/models/status_checks/file_system_status_check.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def value
77
end
88

99
def children
10-
@children ||= source_result['nodes']['nodes'].values.map do |node|
10+
@children ||= source_result['nodes'].values.map do |node|
1111
next if node['attributes'] && node['attributes']['data'] == 'false'
1212
next if node['roles'] && node['roles'].include?('data') == false
1313

lib/proxes/models/status_checks/jvm_heap_status_check.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def value
77
end
88

99
def children
10-
@children ||= source_result['nodes']['nodes'].values.map do |node|
10+
@children ||= source_result['nodes'].values.map do |node|
1111
[
1212
node['name'],
1313
node['jvm']['mem']['heap_used_percent'].to_f

lib/proxes/models/status_checks/memory_status_check.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def value
88
end
99

1010
def children
11-
@children ||= source_result['nodes']['nodes'].values.map do |node|
11+
@children ||= source_result['nodes'].values.map do |node|
1212
[
1313
node['name'],
1414
node['os']['mem']['used_percent'].to_f

lib/proxes/models/status_checks/nodes_status_check.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ def check_node(node)
1717
end
1818

1919
def children
20-
@children ||= source_result['nodes']['nodes'].map do |_id, node|
20+
@children ||= source_result['nodes']&.map do |_id, node|
2121
[node['name'], 1] if check_node(node)
22-
end.compact.to_h
22+
end&.compact.to_h
2323
end
2424

2525
def check

0 commit comments

Comments
 (0)