ntq_tools 0.7.1 → 0.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +7 -0
- data/app/controllers/ntq_tools/monitors_controller.rb +1 -1
- data/lib/ntq_tools/monitor.rb +14 -3
- data/lib/ntq_tools/monitors/base.rb +1 -1
- data/lib/ntq_tools/monitors/configuration.rb +15 -0
- data/lib/ntq_tools/monitors/sidekiq.rb +13 -7
- data/lib/ntq_tools/version.rb +1 -1
- data/lib/ntq_tools.rb +0 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bdfcea4f27002577998567b60bce394305373b5a6bb3a31c9aef29b4f9857abd
|
4
|
+
data.tar.gz: 7ae78c43d5f13ab835aa27b9a31f033c484ad44f511a589216d344ee3fe98806
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9406290d22ab4d908d5f4c6331259039a165c216f97ef393fbdb1ac66f214e9649701937a2618b48de9e932ecb2f713955bf4c0dbb6aca5db18e8e0754e9e04c
|
7
|
+
data.tar.gz: 26a4cf2dc0a34406569134364bc5bc8a3b467edf29cddde3c9eea7eebc7bb3bbfc3d63dbf477b88fbb78954cecf688a40a72181be8fc17f619659d2d81f88cf0
|
data/README.md
CHANGED
@@ -12,6 +12,13 @@ MONITORING_PASSWORD
|
|
12
12
|
MONITORING_USERNAME
|
13
13
|
```
|
14
14
|
|
15
|
+
Vous pouvez également désactiver certains services manuellement
|
16
|
+
```ruby
|
17
|
+
NtqTools::Monitor.configure do |config|
|
18
|
+
config.sidekiq = false
|
19
|
+
end
|
20
|
+
```
|
21
|
+
|
15
22
|
## Installation
|
16
23
|
Add this line to your application's Gemfile:
|
17
24
|
|
@@ -9,7 +9,7 @@ module NtqTools
|
|
9
9
|
|
10
10
|
respond_to do |format|
|
11
11
|
format.json do
|
12
|
-
render json: { status: @status, services_status: @services_status }, status: @status ==
|
12
|
+
render json: { status: @status, services_status: @services_status }, status: @status == :ok ? :ok : :service_unavailable
|
13
13
|
end
|
14
14
|
format.html do
|
15
15
|
end
|
data/lib/ntq_tools/monitor.rb
CHANGED
@@ -1,10 +1,19 @@
|
|
1
1
|
require 'ntq_tools/monitors/redis'
|
2
2
|
require 'ntq_tools/monitors/database'
|
3
3
|
require 'ntq_tools/monitors/sidekiq'
|
4
|
+
require 'ntq_tools/monitors/configuration'
|
4
5
|
|
5
6
|
module NtqTools
|
6
7
|
class Monitor
|
7
8
|
|
9
|
+
def self.configure
|
10
|
+
yield config
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.config
|
14
|
+
@config ||= ::NtqTools::Monitors::Configuration.new
|
15
|
+
end
|
16
|
+
|
8
17
|
# Check if installed services are running, it return a tuple with the status and the services status
|
9
18
|
#
|
10
19
|
# eg: [:ok, [{name: 'redis', status: 'OK'}, {name: 'database', status: 'OK'}]]
|
@@ -14,6 +23,8 @@ module NtqTools
|
|
14
23
|
def self.check
|
15
24
|
services_status = []
|
16
25
|
list.each do |monitor|
|
26
|
+
# skip si le service est désactivé (false) dans la config
|
27
|
+
next if config.respond_to?(monitor.name) && !config.send(monitor.name)
|
17
28
|
next unless monitor.is_installed?
|
18
29
|
|
19
30
|
services_status << {
|
@@ -24,14 +35,14 @@ module NtqTools
|
|
24
35
|
status = services_status.all? { |service| service[:status] == 'OK' } ? :ok : :error
|
25
36
|
[status, services_status]
|
26
37
|
end
|
27
|
-
|
38
|
+
|
28
39
|
def self.list
|
40
|
+
# ATTENTION - Rajouter le nom du nouveau service (:name) dans la class Configuration (attr_accessor)
|
29
41
|
[
|
30
42
|
::NtqTools::Monitors::Redis,
|
31
43
|
::NtqTools::Monitors::Database,
|
32
44
|
::NtqTools::Monitors::Sidekiq
|
33
45
|
]
|
34
46
|
end
|
35
|
-
|
36
47
|
end
|
37
|
-
end
|
48
|
+
end
|
@@ -1,22 +1,28 @@
|
|
1
1
|
require 'ntq_tools/monitors/base'
|
2
|
+
|
2
3
|
module NtqTools
|
3
4
|
module Monitors
|
4
5
|
class Sidekiq < Base
|
5
|
-
|
6
|
+
|
6
7
|
class << self
|
7
8
|
def name
|
8
|
-
|
9
|
+
'sidekiq'
|
9
10
|
end
|
10
|
-
|
11
|
+
|
11
12
|
def is_installed?
|
12
|
-
::Gem.loaded_specs.has_key?(
|
13
|
+
::Gem.loaded_specs.has_key?('sidekiq')
|
13
14
|
end
|
14
|
-
|
15
|
+
|
15
16
|
def check
|
17
|
+
require 'sidekiq/api'
|
16
18
|
::Sidekiq::ProcessSet.new.any? { |process| process['busy'] }
|
19
|
+
rescue LoadError
|
20
|
+
raise LoadError, <<-ERROR
|
21
|
+
::Sidekiq::ProcessSet could not be loaded by gem ntq_tools.
|
22
|
+
It is required for Sidekiq monitoring'
|
23
|
+
ERROR
|
17
24
|
end
|
18
25
|
end
|
19
|
-
|
20
26
|
end
|
21
27
|
end
|
22
|
-
end
|
28
|
+
end
|
data/lib/ntq_tools/version.rb
CHANGED
data/lib/ntq_tools.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ntq_tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -73,6 +73,7 @@ files:
|
|
73
73
|
- lib/ntq_tools/engine.rb
|
74
74
|
- lib/ntq_tools/monitor.rb
|
75
75
|
- lib/ntq_tools/monitors/base.rb
|
76
|
+
- lib/ntq_tools/monitors/configuration.rb
|
76
77
|
- lib/ntq_tools/monitors/database.rb
|
77
78
|
- lib/ntq_tools/monitors/redis.rb
|
78
79
|
- lib/ntq_tools/monitors/sidekiq.rb
|