system_health 0.0.1 → 0.0.2
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 +2 -2
- data/lib/system_health/monitor.rb +4 -15
- data/lib/system_health/version.rb +1 -1
- data/spec/lib/system_health/monitor_spec.rb +12 -18
- data/system_health.gemspec +3 -3
- metadata +7 -9
- data/app/controllers/system_health/monitors_controller.rb +0 -21
- data/config/routes.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41498bf1e7ac698fb8c733b4e76e6132de87ccfc
|
4
|
+
data.tar.gz: 08462eaebb15da5afc0fdd11df42aa3a2634b565
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dcb8a189cb136098debc460611c1c090fd037b7c0553d6ae6503a51098e53619dc62c0136c00121712fecdea97255d5fc9e450787ed93e8879c7cc3d8b431496
|
7
|
+
data.tar.gz: fb37e26556f82e6694539a05be838a41459b195f0ce3a31f6203c6d57f006ea9d9cf28a03a80713370b64cac34e3d74d6133b1e1ae67e53cc35a06d152d14393
|
data/README.md
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
The System Health gem can be added to your Rails application to provide
|
4
4
|
a convenient way to regularly look for bad data or other system health
|
5
|
-
indicators. It provides a single endpoint that will generate
|
5
|
+
indicators. It provides a single endpoint that will generate an error
|
6
6
|
count and enumerate error messages. This count and the messages can be
|
7
|
-
collected by external monitoring tools
|
7
|
+
collected by external monitoring tools that look for the HTTP status code
|
8
8
|
(200 when there are no errors or 500 when there is at least one error)
|
9
9
|
and/or inspect the JSON payload that is returned.
|
10
10
|
|
@@ -4,28 +4,17 @@ module SystemHealth
|
|
4
4
|
@monitor_classes = monitor_classes
|
5
5
|
end
|
6
6
|
|
7
|
-
def as_json(options = nil)
|
8
|
-
{
|
9
|
-
error_count: error_count,
|
10
|
-
messages: messages
|
11
|
-
}
|
12
|
-
end
|
13
|
-
|
14
|
-
def http_status
|
15
|
-
error_count > 0 ? 500 : 200
|
16
|
-
end
|
17
|
-
|
18
|
-
private
|
19
|
-
attr_reader :monitor_classes
|
20
|
-
|
21
7
|
def error_count
|
22
8
|
monitors.sum(&:error_count)
|
23
9
|
end
|
24
10
|
|
25
|
-
def
|
11
|
+
def error_messages
|
26
12
|
monitors.flat_map(&:error_messages)
|
27
13
|
end
|
28
14
|
|
15
|
+
private
|
16
|
+
attr_reader :monitor_classes
|
17
|
+
|
29
18
|
def monitors
|
30
19
|
@monitors ||= monitor_classes.map(&:new)
|
31
20
|
end
|
@@ -21,35 +21,29 @@ module SystemHealth
|
|
21
21
|
and_return(['something broke'])
|
22
22
|
end
|
23
23
|
|
24
|
-
describe '#
|
25
|
-
it 'returns
|
26
|
-
expect(monitor.
|
27
|
-
error_count: 1,
|
28
|
-
messages: ['something broke']
|
29
|
-
})
|
24
|
+
describe '#error_count' do
|
25
|
+
it 'returns error count' do
|
26
|
+
expect(monitor.error_count).to eq(1)
|
30
27
|
end
|
31
28
|
end
|
32
29
|
|
33
|
-
describe '#
|
34
|
-
it 'returns
|
35
|
-
expect(monitor.
|
30
|
+
describe '#messages' do
|
31
|
+
it 'returns error messages' do
|
32
|
+
expect(monitor.error_messages).to eq(['something broke'])
|
36
33
|
end
|
37
34
|
end
|
38
35
|
end
|
39
36
|
|
40
37
|
context 'when no errors' do
|
41
|
-
describe '#
|
42
|
-
it 'returns
|
43
|
-
expect(monitor.
|
44
|
-
error_count: 0,
|
45
|
-
messages: []
|
46
|
-
})
|
38
|
+
describe '#error_count' do
|
39
|
+
it 'returns error count' do
|
40
|
+
expect(monitor.error_count).to eq(0)
|
47
41
|
end
|
48
42
|
end
|
49
43
|
|
50
|
-
describe '#
|
51
|
-
it 'returns
|
52
|
-
expect(monitor.
|
44
|
+
describe '#messages' do
|
45
|
+
it 'returns error messages' do
|
46
|
+
expect(monitor.error_messages).to eq([])
|
53
47
|
end
|
54
48
|
end
|
55
49
|
end
|
data/system_health.gemspec
CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Stirling Olson"]
|
10
10
|
spec.email = ["seo@foraker.com"]
|
11
11
|
spec.summary = %q{System health monitor for Rails apps}
|
12
|
-
spec.description = %q{}
|
13
|
-
spec.homepage = ""
|
12
|
+
spec.description = %q{System health monitor for Rails applications}
|
13
|
+
spec.homepage = "https://github.com/foraker/system_health"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_dependency "rails"
|
21
|
+
spec.add_dependency "rails", '~> 4'
|
22
22
|
|
23
23
|
spec.add_development_dependency "bundler", "~> 1.6"
|
24
24
|
spec.add_development_dependency "rake"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: system_health
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stirling Olson
|
@@ -14,16 +14,16 @@ dependencies:
|
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '4'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '4'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,7 +66,7 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
description:
|
69
|
+
description: System health monitor for Rails applications
|
70
70
|
email:
|
71
71
|
- seo@foraker.com
|
72
72
|
executables: []
|
@@ -80,8 +80,6 @@ files:
|
|
80
80
|
- LICENSE.txt
|
81
81
|
- README.md
|
82
82
|
- Rakefile
|
83
|
-
- app/controllers/system_health/monitors_controller.rb
|
84
|
-
- config/routes.rb
|
85
83
|
- lib/system_health.rb
|
86
84
|
- lib/system_health/configuration.rb
|
87
85
|
- lib/system_health/engine.rb
|
@@ -90,7 +88,7 @@ files:
|
|
90
88
|
- lib/system_health/version.rb
|
91
89
|
- spec/lib/system_health/monitor_spec.rb
|
92
90
|
- system_health.gemspec
|
93
|
-
homepage:
|
91
|
+
homepage: https://github.com/foraker/system_health
|
94
92
|
licenses:
|
95
93
|
- MIT
|
96
94
|
metadata: {}
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module SystemHealth
|
2
|
-
class MonitorsController < ApplicationController
|
3
|
-
http_basic_authenticate_with \
|
4
|
-
name: ENV['SYSTEM_HEALTH_USERNAME'],
|
5
|
-
password: ENV['SYSTEM_HEALTH_PASSWORD']
|
6
|
-
|
7
|
-
def show
|
8
|
-
render json: monitor.as_json, status: monitor.http_status
|
9
|
-
end
|
10
|
-
|
11
|
-
private
|
12
|
-
|
13
|
-
def monitor
|
14
|
-
@monitor ||= SystemHealth::Monitor.new(monitor_classes)
|
15
|
-
end
|
16
|
-
|
17
|
-
def monitor_classes
|
18
|
-
SystemHealth.configuration.monitor_classes
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|