health-monitor-rails 7.0.1 → 7.1.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 +60 -1
- data/lib/health_monitor/providers/redis.rb +19 -1
- data/lib/health_monitor/providers/sidekiq.rb +1 -1
- data/lib/health_monitor/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c8cfa2355d53ebd52b3fcfca54155d487327ca9
|
4
|
+
data.tar.gz: d2ebfea5cce81c6873e2238c9c5a1118b1a3bda4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d545e866dd23e34b6461f8c6d2b5f4750322dfce9e0915d510b45d62b092dcd14f69dd5ed8fc5c95683ccd6275a3878c0c6762ccf97df1277b82ed0b23ee8fe
|
7
|
+
data.tar.gz: aab2f11832003e6329e916a3ae6b4a01502cab105f16463b6c4bedf39e53ace458ae414bda30b103f370581d65051bda88419c4630683f608ffab4200bdea367
|
data/README.md
CHANGED
@@ -155,12 +155,25 @@ HealthMonitor.configure do |config|
|
|
155
155
|
end
|
156
156
|
```
|
157
157
|
|
158
|
+
```ruby
|
159
|
+
HealthMonitor.configure do |config|
|
160
|
+
config.redis.configure do |redis_config|
|
161
|
+
redis_config.url = 'redis://user:pass@example.redis.com:90210/'
|
162
|
+
end
|
163
|
+
end
|
164
|
+
```
|
165
|
+
|
158
166
|
The currently supported settings are:
|
159
167
|
|
160
168
|
#### Sidekiq
|
161
169
|
|
162
170
|
* `latency`: the latency (in seconds) of a queue (now - when the oldest job was enqueued) which is considered unhealthy (the default is 30 seconds, but larger processing queue should have a larger latency value).
|
163
171
|
|
172
|
+
#### Redis
|
173
|
+
|
174
|
+
* `url`: the url used to connect to your Redis instance - note, this is an optional configuration and will use the default connection if not specified
|
175
|
+
|
176
|
+
|
164
177
|
### Adding a custom provider
|
165
178
|
It's also possible to add custom health check providers suited for your needs (of course, it's highly appreciated and encouraged if you'd contribute useful providers to the project).
|
166
179
|
|
@@ -220,11 +233,57 @@ HealthMonitor.configure do |config|
|
|
220
233
|
end
|
221
234
|
```
|
222
235
|
|
236
|
+
### Monitoring script
|
237
|
+
|
238
|
+
A Nagios/Shinken/Icinga/Icinga2 plugin is available in `extra` directory.
|
239
|
+
|
240
|
+
It takes one argument : `-u` or `--uri`
|
241
|
+
|
242
|
+
```sh
|
243
|
+
nicolas@desktop:$ ./check_rails.rb
|
244
|
+
missing argument: uri
|
245
|
+
|
246
|
+
Usage: check_rails.rb -u uri
|
247
|
+
-u, --uri URI The URI to check (https://nagios:nagios@example.com/check.json)
|
248
|
+
|
249
|
+
Common options:
|
250
|
+
-v, --version Displays Version
|
251
|
+
-h, --help Displays Help
|
252
|
+
```
|
253
|
+
|
254
|
+
And it generates an output with the right status code for your monitoring system :
|
255
|
+
|
256
|
+
```sh
|
257
|
+
nicolas@desktop:$ ./check_rails.rb -u http://admin:admin@localhost:5000/check.json
|
258
|
+
Rails application : OK
|
259
|
+
|
260
|
+
Database : OK
|
261
|
+
Cache : OK
|
262
|
+
Redis : OK
|
263
|
+
Sidekiq : OK
|
264
|
+
|
265
|
+
nicolas@desktop:$ echo $?
|
266
|
+
0
|
267
|
+
```
|
268
|
+
|
269
|
+
```sh
|
270
|
+
nicolas@desktop:$ ./check_rails.rb -u http://admin:admin@localhost:5000/check.json
|
271
|
+
Rails application : ERROR
|
272
|
+
|
273
|
+
Database : OK
|
274
|
+
Cache : OK
|
275
|
+
Redis : ERROR (Error connecting to Redis on 127.0.0.1:6379 (Errno::ECONNREFUSED))
|
276
|
+
Sidekiq : ERROR (Error connecting to Redis on 127.0.0.1:6379 (Errno::ECONNREFUSED))
|
277
|
+
|
278
|
+
nicolas@desktop:$ echo $?
|
279
|
+
2
|
280
|
+
```
|
281
|
+
|
223
282
|
## License
|
224
283
|
|
225
284
|
The MIT License (MIT)
|
226
285
|
|
227
|
-
Copyright (c)
|
286
|
+
Copyright (c) 2017
|
228
287
|
|
229
288
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
230
289
|
this software and associated documentation files (the "Software"), to deal in
|
@@ -5,10 +5,28 @@ module HealthMonitor
|
|
5
5
|
class RedisException < StandardError; end
|
6
6
|
|
7
7
|
class Redis < Base
|
8
|
+
class Configuration
|
9
|
+
DEFAULT_URL = nil
|
10
|
+
|
11
|
+
attr_accessor :url
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
@url = DEFAULT_URL
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class << self
|
19
|
+
private
|
20
|
+
|
21
|
+
def configuration_class
|
22
|
+
::HealthMonitor::Providers::Redis::Configuration
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
8
26
|
def check!
|
9
27
|
time = Time.now.to_s(:rfc2822)
|
10
28
|
|
11
|
-
redis = ::Redis.new
|
29
|
+
redis = configuration.url ? ::Redis.new(url: configuration.url) : ::Redis.new
|
12
30
|
redis.set(key, time)
|
13
31
|
fetched = redis.get(key)
|
14
32
|
|
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: 7.0
|
4
|
+
version: 7.1.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: 2017-03-
|
11
|
+
date: 2017-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|