health-monitor-rails 9.2.0 → 9.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/controllers/health_monitor/health_controller.rb +1 -0
- data/app/views/health_monitor/health/check.html.erb +31 -6
- data/lib/health_monitor/configuration.rb +6 -1
- data/lib/health_monitor/providers/base.rb +8 -2
- data/lib/health_monitor/providers/redis.rb +16 -8
- data/lib/health_monitor/providers/sidekiq.rb +2 -0
- data/lib/health_monitor/version.rb +1 -1
- metadata +38 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e3901481f04e5dbca447ec01e0e551dc0d6788b82e48ecc681fdf598f7d1094
|
4
|
+
data.tar.gz: 1fb26a9ff50047e499d810834b0c44b354d23e5587dabb9d8da7d6dca2e7fa85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2074e27e809d298e5b65eeef3d8a3c8b6215ae530f056a66cec0d8f561bdf04e45cefa62f5e7af14f5dc2457bd6823db671ff4ce8fdbd6aa6ccde486bb67c0d9
|
7
|
+
data.tar.gz: b62478c0bbcbd00295ab63a4846397ace4882d49508385faeb7cd794e3f09b1127a532603320c1567727882965cd840b59352a537913a488119bb8ee238a58c3
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# health-monitor-rails
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/health-monitor-rails.svg)](http://badge.fury.io/rb/health-monitor-rails)
|
4
|
-
[![Build Status](https://
|
4
|
+
[![Build Status](https://github.com/lbeder/health-monitor-rails/actions/workflows/ci.yml/badge.svg)](https://github.com/lbeder/health-monitor-rails/actions/workflows/ci.yml)
|
5
5
|
[![Coverage Status](https://coveralls.io/repos/lbeder/health-monitor-rails/badge.svg)](https://coveralls.io/r/lbeder/health-monitor-rails)
|
6
6
|
|
7
7
|
This is a health monitoring Rails mountable plug-in, which checks various services (db, cache, sidekiq, redis, etc.).
|
@@ -17,7 +17,7 @@
|
|
17
17
|
<main>
|
18
18
|
<div class="max-w-7xl mx-auto py-12 sm:px-6 lg:px-8">
|
19
19
|
<div class="max-w-4xl mx-auto">
|
20
|
-
<div class="bg-white shadow overflow-hidden sm:rounded-lg">
|
20
|
+
<div class="services bg-white shadow overflow-hidden sm:rounded-lg">
|
21
21
|
<div class="px-4 py-5 sm:px-6">
|
22
22
|
<h3 class="text-lg leading-6 font-medium text-gray-900">
|
23
23
|
Services
|
@@ -43,13 +43,38 @@
|
|
43
43
|
</dl>
|
44
44
|
</div>
|
45
45
|
</div>
|
46
|
+
<% if @statuses[:environment_variables].present? %>
|
47
|
+
<div class="env-variables bg-white shadow overflow-hidden sm:rounded-lg my-6">
|
48
|
+
<div class="px-4 py-5 sm:px-6">
|
49
|
+
<h3 class="text-lg leading-6 font-medium text-gray-900">
|
50
|
+
Environment Variables
|
51
|
+
</h3>
|
52
|
+
</div>
|
53
|
+
<div class="border-t border-gray-200">
|
54
|
+
<dl>
|
55
|
+
<% @statuses[:environment_variables].each_with_index do |env_var, index| %>
|
56
|
+
<div class="<%= index.odd? ? 'bg-gray-50' : 'bg-white' %> px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
|
57
|
+
<dt class="text-sm font-medium text-gray-500">
|
58
|
+
<%= env_var[0] %>
|
59
|
+
</dt>
|
60
|
+
<dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
|
61
|
+
<%= env_var[1] %>
|
62
|
+
</dd>
|
63
|
+
</div>
|
64
|
+
<% end %>
|
65
|
+
</dl>
|
66
|
+
</div>
|
67
|
+
</div>
|
68
|
+
<% end %>
|
46
69
|
</div>
|
47
70
|
</div>
|
48
71
|
</main>
|
49
|
-
|
50
|
-
<
|
51
|
-
|
52
|
-
|
53
|
-
|
72
|
+
<% if !@hide_footer %>
|
73
|
+
<footer>
|
74
|
+
<div class="font-light text-center text-slate-500 text-xs px-5">
|
75
|
+
Powered by <a href="https://github.com/lbeder/health-monitor-rails" target="_blank">health-monitor-rails</a>
|
76
|
+
</div>
|
77
|
+
</footer>
|
78
|
+
<% end %>
|
54
79
|
</body>
|
55
80
|
</html>
|
@@ -7,6 +7,7 @@ module HealthMonitor
|
|
7
7
|
attr_accessor :basic_auth_credentials,
|
8
8
|
:environment_variables,
|
9
9
|
:error_callback,
|
10
|
+
:hide_footer,
|
10
11
|
:path
|
11
12
|
attr_reader :providers
|
12
13
|
|
@@ -21,7 +22,11 @@ module HealthMonitor
|
|
21
22
|
PROVIDERS.each do |provider_name|
|
22
23
|
define_method provider_name do |&_block|
|
23
24
|
require "health_monitor/providers/#{provider_name}"
|
24
|
-
|
25
|
+
|
26
|
+
add_provider(
|
27
|
+
"HealthMonitor::Providers::#{provider_name.to_s.titleize.delete(' ')}"
|
28
|
+
.constantize
|
29
|
+
)
|
25
30
|
end
|
26
31
|
end
|
27
32
|
|
@@ -3,6 +3,8 @@
|
|
3
3
|
module HealthMonitor
|
4
4
|
module Providers
|
5
5
|
class Base
|
6
|
+
@global_configuration = nil
|
7
|
+
|
6
8
|
attr_reader :request
|
7
9
|
attr_accessor :configuration
|
8
10
|
|
@@ -10,10 +12,14 @@ module HealthMonitor
|
|
10
12
|
@provider_name ||= name.demodulize
|
11
13
|
end
|
12
14
|
|
15
|
+
def self.global_configuration
|
16
|
+
@global_configuration ||= configuration_class.new
|
17
|
+
end
|
18
|
+
|
13
19
|
def self.configure
|
14
20
|
return unless configurable?
|
15
21
|
|
16
|
-
@global_configuration
|
22
|
+
@global_configuration ||= configuration_class.new
|
17
23
|
|
18
24
|
yield @global_configuration if block_given?
|
19
25
|
end
|
@@ -23,7 +29,7 @@ module HealthMonitor
|
|
23
29
|
|
24
30
|
return unless self.class.configurable?
|
25
31
|
|
26
|
-
self.configuration = self.class.
|
32
|
+
self.configuration = self.class.global_configuration
|
27
33
|
end
|
28
34
|
|
29
35
|
# @abstract
|
@@ -4,6 +4,8 @@ require 'health_monitor/providers/base'
|
|
4
4
|
|
5
5
|
module HealthMonitor
|
6
6
|
module Providers
|
7
|
+
CONNECTION_POOL_SIZE = 1
|
8
|
+
|
7
9
|
class RedisException < StandardError; end
|
8
10
|
|
9
11
|
class Redis < Base
|
@@ -23,6 +25,10 @@ module HealthMonitor
|
|
23
25
|
def configuration_class
|
24
26
|
::HealthMonitor::Providers::Redis::Configuration
|
25
27
|
end
|
28
|
+
|
29
|
+
def as_connection_pool(connection)
|
30
|
+
ConnectionPool.new(size: CONNECTION_POOL_SIZE) { connection }
|
31
|
+
end
|
26
32
|
end
|
27
33
|
|
28
34
|
def check!
|
@@ -30,8 +36,6 @@ module HealthMonitor
|
|
30
36
|
check_max_used_memory!
|
31
37
|
rescue Exception => e
|
32
38
|
raise RedisException.new(e.message)
|
33
|
-
ensure
|
34
|
-
redis.close
|
35
39
|
end
|
36
40
|
|
37
41
|
private
|
@@ -39,8 +43,8 @@ module HealthMonitor
|
|
39
43
|
def check_values!
|
40
44
|
time = Time.now.to_formatted_s(:rfc2822)
|
41
45
|
|
42
|
-
redis.set(key, time)
|
43
|
-
fetched = redis.get(key)
|
46
|
+
redis.with { |conn| conn.set(key, time) }
|
47
|
+
fetched = redis.with { |conn| conn.get(key) }
|
44
48
|
|
45
49
|
raise "different values (now: #{time}, fetched: #{fetched})" if fetched != time
|
46
50
|
end
|
@@ -59,11 +63,15 @@ module HealthMonitor
|
|
59
63
|
def redis
|
60
64
|
@redis =
|
61
65
|
if configuration.connection
|
62
|
-
configuration.connection
|
66
|
+
if configuration.connection.is_a?(ConnectionPool)
|
67
|
+
configuration.connection
|
68
|
+
else
|
69
|
+
ConnectionPool.new(size: CONNECTION_POOL_SIZE) { configuration.connection }
|
70
|
+
end
|
63
71
|
elsif configuration.url
|
64
|
-
::Redis.new(url: configuration.url)
|
72
|
+
ConnectionPool.new(size: CONNECTION_POOL_SIZE) { ::Redis.new(url: configuration.url) }
|
65
73
|
else
|
66
|
-
::Redis.new
|
74
|
+
ConnectionPool.new(size: CONNECTION_POOL_SIZE) { ::Redis.new }
|
67
75
|
end
|
68
76
|
end
|
69
77
|
|
@@ -72,7 +80,7 @@ module HealthMonitor
|
|
72
80
|
end
|
73
81
|
|
74
82
|
def used_memory_mb
|
75
|
-
bytes_to_megabytes(redis.info['used_memory'])
|
83
|
+
bytes_to_megabytes(redis.with { |conn| conn.info['used_memory'] })
|
76
84
|
end
|
77
85
|
end
|
78
86
|
end
|
@@ -73,6 +73,7 @@ module HealthMonitor
|
|
73
73
|
|
74
74
|
def check_processes!
|
75
75
|
sidekiq_stats = ::Sidekiq::Stats.new
|
76
|
+
|
76
77
|
return unless sidekiq_stats.processes_size.zero?
|
77
78
|
|
78
79
|
raise 'Sidekiq alive processes number is 0!'
|
@@ -89,6 +90,7 @@ module HealthMonitor
|
|
89
90
|
def check_queue_size!
|
90
91
|
configuration.queues.each do |queue, config|
|
91
92
|
size = queue(queue).size
|
93
|
+
|
92
94
|
raise "queue '#{queue}': size #{size} is greater than #{config[:queue_size]}" if size > config[:queue_size]
|
93
95
|
end
|
94
96
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: health-monitor-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 9.
|
4
|
+
version: 9.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leonid Beder
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -67,7 +67,7 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: coveralls_reborn
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
@@ -109,7 +109,7 @@ dependencies:
|
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '4.1'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
112
|
+
name: mock_redis
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - ">="
|
@@ -123,7 +123,7 @@ dependencies:
|
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
126
|
+
name: pry
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
129
|
- - ">="
|
@@ -137,19 +137,19 @@ dependencies:
|
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
|
-
name:
|
140
|
+
name: rake
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
143
|
- - ">="
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version:
|
145
|
+
version: '0'
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
150
|
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version:
|
152
|
+
version: '0'
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: resque
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -184,14 +184,42 @@ dependencies:
|
|
184
184
|
requirements:
|
185
185
|
- - ">="
|
186
186
|
- !ruby/object:Gem::Version
|
187
|
-
version: '0
|
187
|
+
version: '0'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: rubocop-rake
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - ">="
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0'
|
188
202
|
type: :development
|
189
203
|
prerelease: false
|
190
204
|
version_requirements: !ruby/object:Gem::Requirement
|
191
205
|
requirements:
|
192
206
|
- - ">="
|
193
207
|
- !ruby/object:Gem::Version
|
194
|
-
version: '0
|
208
|
+
version: '0'
|
209
|
+
- !ruby/object:Gem::Dependency
|
210
|
+
name: rubocop-rspec
|
211
|
+
requirement: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - ">="
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: '0'
|
216
|
+
type: :development
|
217
|
+
prerelease: false
|
218
|
+
version_requirements: !ruby/object:Gem::Requirement
|
219
|
+
requirements:
|
220
|
+
- - ">="
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: '0'
|
195
223
|
- !ruby/object:Gem::Dependency
|
196
224
|
name: sidekiq
|
197
225
|
requirement: !ruby/object:Gem::Requirement
|