Class: ProxES::FileSystemStatusCheck

Inherits:
StatusCheck
  • Object
show all
Defined in:
lib/proxes/models/status_checks/file_system_status_check.rb

Constant Summary

Constants inherited from StatusCheck

StatusCheck::SOURCE_CALLS

Instance Method Summary collapse

Methods inherited from StatusCheck

#passed?, #policy_class, #source_result, source_result, #validate

Methods included from Services::ES

#client, #conn, #ssl_store

Instance Method Details

#checkObject



22
23
24
25
26
# File 'lib/proxes/models/status_checks/file_system_status_check.rb', line 22

def check
  return true if required_value.blank?

  value > required_value.to_f
end

#childrenObject



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/proxes/models/status_checks/file_system_status_check.rb', line 9

def children
  @children ||= source_result['nodes']['nodes'].values.map do |node|
    next if node['attributes'] && node['attributes']['data'] == 'false'
    next if node['roles'] && node['roles'].include?('data') == false

    stats = node['fs']['total']
    [
      node['name'],
      stats['available_in_bytes'] / stats['total_in_bytes'].to_f * 100
    ]
  end.compact.to_h
end

#formatted(val = nil) ⇒ Object



28
29
30
# File 'lib/proxes/models/status_checks/file_system_status_check.rb', line 28

def formatted(val = nil)
  format('%.4f%% Minimum Free', val || value)
end

#valueObject



5
6
7
# File 'lib/proxes/models/status_checks/file_system_status_check.rb', line 5

def value
  children.values.min
end