Class: NtqTools::Monitor
- Inherits:
-
Object
- Object
- NtqTools::Monitor
- Defined in:
- lib/ntq_tools/monitor.rb
Class Method Summary collapse
-
.check ⇒ Symbol, Array<Hash>
Check if installed services are running, it return a tuple with the status and the services status.
- .config ⇒ Object
- .configure {|config| ... } ⇒ Object
- .list ⇒ Object
Class Method Details
.check ⇒ Symbol, 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’]]
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 |
.config ⇒ Object
13 14 15 |
# File 'lib/ntq_tools/monitor.rb', line 13 def self.config @config ||= ::NtqTools::Monitors::Configuration.new end |
.configure {|config| ... } ⇒ Object
9 10 11 |
# File 'lib/ntq_tools/monitor.rb', line 9 def self.configure yield config end |