Class: NtqTools::Monitor

Inherits:
Object
  • Object
show all
Defined in:
lib/ntq_tools/monitor.rb

Class Method Summary collapse

Class Method Details

.checkSymbol, Array<Hash>

Check if installed services are running, it return a tuple with the status and the services status

eg: [:ok, [‘redis’, status: ‘OK’, ‘database’, status: ‘OK’]] eg: [:error, [‘redis’, status: ‘OK’, ‘database’, status: ‘ERROR’]]

Returns:

  • (Symbol, Array<Hash>)


23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/ntq_tools/monitor.rb', line 23

def self.check
  services_status = []
  list.each do |monitor|
    # skip si le service est désactivé (false) dans la config
    next if config.respond_to?(monitor.name) && !config.send(monitor.name)
    next unless monitor.is_installed?

    services_status << {
      name: monitor.name,
      status: monitor.check ? 'OK' : 'ERROR'
    }
  end
  status = services_status.all? { |service| service[:status] == 'OK' } ? :ok : :error
  [status, services_status]
end

.configObject



13
14
15
# File 'lib/ntq_tools/monitor.rb', line 13

def self.config
  @config ||= ::NtqTools::Monitors::Configuration.new
end

.configure {|config| ... } ⇒ Object

Yields:



9
10
11
# File 'lib/ntq_tools/monitor.rb', line 9

def self.configure
  yield config
end

.listObject



39
40
41
42
43
44
45
46
# File 'lib/ntq_tools/monitor.rb', line 39

def self.list
  # ATTENTION - Rajouter le nom du nouveau service (:name) dans la class Configuration (attr_accessor)
  [
    ::NtqTools::Monitors::Redis,
    ::NtqTools::Monitors::Database,
    ::NtqTools::Monitors::Sidekiq
  ]
end