heartcheck 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.rubocop.yml +14 -0
- data/.travis.yml +11 -0
- data/CHANGELOG +6 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +64 -0
- data/LICENSE.txt +20 -0
- data/README.md +73 -0
- data/Rakefile +1 -0
- data/bin/console +12 -0
- data/bin/rspec +16 -0
- data/{bin → exe}/heartcheck +0 -0
- data/heartcheck.gemspec +30 -0
- data/lib/heartcheck.rb +9 -1
- data/lib/heartcheck/app.rb +3 -0
- data/lib/heartcheck/checks/base.rb +96 -9
- data/lib/heartcheck/checks/watch_file.rb +1 -1
- data/lib/heartcheck/controllers/base.rb +7 -3
- data/lib/heartcheck/executors.rb +1 -0
- data/lib/heartcheck/executors/base.rb +15 -0
- data/lib/heartcheck/generators/templates/config.rb +27 -3
- data/lib/heartcheck/logger.rb +1 -0
- data/lib/heartcheck/version.rb +1 -1
- metadata +21 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a438aab551507bb1d4e8ec150534d5555ee6de5
|
4
|
+
data.tar.gz: 50536531483c713aa998d859ddeba43fe3723a2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f7a5808ea6b8f8de2eafa651e07daf4dfdaa4f8b1c2192a37893b1c1c087f3ae238235079493c3f0fdbee1e572b234cf058ed962e7473acb503861f0cb7a4aa
|
7
|
+
data.tar.gz: 430f2303f3c4386d32ef5aed5c6f77a82bd977b462b2daf19ab31f4151d686c4a9c99a8ff1f598beb0726e49da8e92d8d197f6c9dcd73e8add39c2ca797846c8
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.travis.yml
ADDED
data/CHANGELOG
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
heartcheck (1.0.5)
|
5
|
+
oj
|
6
|
+
rack (~> 1, >= 1.4.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
ast (2.0.0)
|
12
|
+
astrolabe (1.3.1)
|
13
|
+
parser (~> 2.2)
|
14
|
+
coderay (1.1.0)
|
15
|
+
diff-lcs (1.2.5)
|
16
|
+
method_source (0.8.2)
|
17
|
+
oj (2.12.10)
|
18
|
+
parser (2.2.2.6)
|
19
|
+
ast (>= 1.1, < 3.0)
|
20
|
+
powerpack (0.0.9)
|
21
|
+
pry (0.10.1)
|
22
|
+
coderay (~> 1.1.0)
|
23
|
+
method_source (~> 0.8.1)
|
24
|
+
slop (~> 3.4)
|
25
|
+
pry-nav (0.2.4)
|
26
|
+
pry (>= 0.9.10, < 0.11.0)
|
27
|
+
rack (1.6.4)
|
28
|
+
rack-test (0.6.3)
|
29
|
+
rack (>= 1.0)
|
30
|
+
rainbow (2.0.0)
|
31
|
+
rspec (3.1.0)
|
32
|
+
rspec-core (~> 3.1.0)
|
33
|
+
rspec-expectations (~> 3.1.0)
|
34
|
+
rspec-mocks (~> 3.1.0)
|
35
|
+
rspec-core (3.1.7)
|
36
|
+
rspec-support (~> 3.1.0)
|
37
|
+
rspec-expectations (3.1.2)
|
38
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
39
|
+
rspec-support (~> 3.1.0)
|
40
|
+
rspec-mocks (3.1.3)
|
41
|
+
rspec-support (~> 3.1.0)
|
42
|
+
rspec-support (3.1.2)
|
43
|
+
rubocop (0.27.1)
|
44
|
+
astrolabe (~> 1.3)
|
45
|
+
parser (>= 2.2.0.pre.7, < 3.0)
|
46
|
+
powerpack (~> 0.0.6)
|
47
|
+
rainbow (>= 1.99.1, < 3.0)
|
48
|
+
ruby-progressbar (~> 1.4)
|
49
|
+
ruby-progressbar (1.7.5)
|
50
|
+
slop (3.6.0)
|
51
|
+
thor (0.19.1)
|
52
|
+
yard (0.8.7.6)
|
53
|
+
|
54
|
+
PLATFORMS
|
55
|
+
ruby
|
56
|
+
|
57
|
+
DEPENDENCIES
|
58
|
+
heartcheck!
|
59
|
+
pry-nav (~> 0.2.0, >= 0.2.4)
|
60
|
+
rack-test (~> 0.6.0, >= 0.6.3)
|
61
|
+
rspec (~> 3.1.0, >= 3.1.0)
|
62
|
+
rubocop (~> 0.27.0, >= 0.27.1)
|
63
|
+
thor (~> 0.19.0, >= 0.19.1)
|
64
|
+
yard (~> 0.8.0, >= 0.8.7.6)
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2015 Locaweb
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
Heartcheck
|
2
|
+
==============
|
3
|
+
|
4
|
+
[![Build Status](https://travis-ci.org/locaweb/heartcheck.svg)](https://travis-ci.org/locaweb/heartcheck)
|
5
|
+
|
6
|
+
Check your applications' heart.
|
7
|
+
|
8
|
+
About
|
9
|
+
-----
|
10
|
+
|
11
|
+
### Endpoint JSON documentation:
|
12
|
+
|
13
|
+
https://github.com/locaweb/heartcheck/wiki/Endpoint-Json
|
14
|
+
|
15
|
+
## How to setup
|
16
|
+
|
17
|
+
1. Include the gem in your Gemfile:
|
18
|
+
|
19
|
+
```
|
20
|
+
gem 'heartcheck'
|
21
|
+
```
|
22
|
+
|
23
|
+
2. Install the gem:
|
24
|
+
|
25
|
+
```
|
26
|
+
bundle install
|
27
|
+
```
|
28
|
+
|
29
|
+
3. Generate some required files according to the framework you are using:
|
30
|
+
|
31
|
+
```
|
32
|
+
heartcheck rails
|
33
|
+
heartcheck padrino
|
34
|
+
heartcheck sinatra
|
35
|
+
```
|
36
|
+
|
37
|
+
4. After that, follow the instructions, edit the generated files and restart your server.
|
38
|
+
|
39
|
+
5. Done! Now you are able to access `[host]/monitoring` and check the monitoring JSON!
|
40
|
+
|
41
|
+
## Routes
|
42
|
+
* `[host]/monitoring`
|
43
|
+
* To check if the app and its integrations are avaiable;
|
44
|
+
* Directed for verifying the app SLA;
|
45
|
+
* `[host]/monitoring/info`
|
46
|
+
* To view some informations that you can configure;
|
47
|
+
* Directed for availability check from load balanced and get info about the installed app;
|
48
|
+
* `[host]/monitoring/functional`
|
49
|
+
* To check if the app is healty (no async job failed and other checks that aren't related to app availability);
|
50
|
+
* Directed for verifying consistency problems within the app;
|
51
|
+
* `[host]/monitoring/dev`
|
52
|
+
* Directed for the development team;
|
53
|
+
* It's run the essential and functional checks;
|
54
|
+
* `[host]/monitoring/health_check`
|
55
|
+
* To check if the app is up and running
|
56
|
+
|
57
|
+
## How to use
|
58
|
+
|
59
|
+
You can see how to use in template that is generated when install:
|
60
|
+
https://github.com/locaweb/heartcheck/blob/master/lib/heartcheck/generators/templates/config.rb
|
61
|
+
|
62
|
+
## Git tags
|
63
|
+
|
64
|
+
Don't forget to tag your work! After a merge request being accepted, run:
|
65
|
+
|
66
|
+
1 - (git tag -a "x.x.x" -m "") to create the new tag.
|
67
|
+
2 - (git push origin "x.x.x") to push the new tag to remote.
|
68
|
+
|
69
|
+
Follow the RubyGems conventions at http://docs.rubygems.org/read/chapter/7 to know how to increment the version number. Covered in more detail in http://semver.org/
|
70
|
+
|
71
|
+
## Merge requests acceptance
|
72
|
+
|
73
|
+
Don't forget to write tests to all your code. It's very important to maintain the codebase's sanity. Any merge request that doesn't have enough test coverage will be asked a revision
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
data/bin/console
ADDED
data/bin/rspec
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'rspec' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('rspec-core', 'rspec')
|
data/{bin → exe}/heartcheck
RENAMED
File without changes
|
data/heartcheck.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'heartcheck/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'heartcheck'
|
7
|
+
spec.version = Heartcheck::VERSION
|
8
|
+
spec.authors = ['Locaweb']
|
9
|
+
spec.email = ['desenvolvedores@locaweb.com.br']
|
10
|
+
spec.homepage = 'http://developer.locaweb.com.br'
|
11
|
+
spec.summary = 'A simple way to check if your app is runnig like as expected.'
|
12
|
+
spec.description = 'A simple way to check your app heart.'
|
13
|
+
spec.license = 'MIT'
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
16
|
+
spec.bindir = "exe"
|
17
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_runtime_dependency 'rack', '~> 1', '>= 1.4.0'
|
21
|
+
spec.add_runtime_dependency 'oj'
|
22
|
+
|
23
|
+
spec.add_development_dependency 'pry-nav', '~> 0.2.0', '>= 0.2.4'
|
24
|
+
spec.add_development_dependency 'rspec', '~> 3.1.0', '>= 3.1.0'
|
25
|
+
spec.add_development_dependency 'rubocop', '~> 0.27.0', '>= 0.27.1'
|
26
|
+
spec.add_development_dependency 'thor', '~> 0.19.0', '>= 0.19.1'
|
27
|
+
spec.add_development_dependency 'rack-test', '~> 0.6.0', '>= 0.6.3'
|
28
|
+
# for documentation
|
29
|
+
spec.add_development_dependency 'yard', '~> 0.8.0', '>= 0.8.7.6'
|
30
|
+
end
|
data/lib/heartcheck.rb
CHANGED
@@ -2,6 +2,7 @@ module Heartcheck
|
|
2
2
|
require 'logger'
|
3
3
|
require 'heartcheck/app'
|
4
4
|
require 'heartcheck/checks'
|
5
|
+
require 'heartcheck/executors'
|
5
6
|
require 'heartcheck/errors'
|
6
7
|
require 'heartcheck/services'
|
7
8
|
require 'heartcheck/logger'
|
@@ -11,6 +12,7 @@ module Heartcheck
|
|
11
12
|
class << self
|
12
13
|
# @attr [Array<Checks>] the checks to use when checking
|
13
14
|
attr_accessor :checks
|
15
|
+
|
14
16
|
# @attr_writer [Object] change the default logger
|
15
17
|
attr_writer :logger
|
16
18
|
|
@@ -26,10 +28,12 @@ module Heartcheck
|
|
26
28
|
# Is used to configure.
|
27
29
|
#
|
28
30
|
# @yield A bock that recieve the class
|
31
|
+
#
|
29
32
|
# @example
|
30
33
|
# Heartcheck.setup do |c|
|
31
34
|
# puts c
|
32
35
|
# end
|
36
|
+
#
|
33
37
|
# @return [void]
|
34
38
|
def setup
|
35
39
|
yield(self)
|
@@ -42,10 +46,12 @@ module Heartcheck
|
|
42
46
|
# @param [Hash] options the options to create an instance of a check.
|
43
47
|
# @option options [String] :class The class name to get an instance
|
44
48
|
# @yield a block to config the instance
|
49
|
+
#
|
45
50
|
# @example
|
46
51
|
# Heartcheck.add(:base) do |c|
|
47
52
|
# c.name = 'Base check'
|
48
53
|
# end
|
54
|
+
#
|
49
55
|
# @return [void]
|
50
56
|
def add(name, options = {}, &block)
|
51
57
|
class_name = options.fetch(:class) { constantize(name) }
|
@@ -100,9 +106,11 @@ module Heartcheck
|
|
100
106
|
|
101
107
|
# helper method to get a constant
|
102
108
|
#
|
109
|
+
# @param [String] name of class
|
110
|
+
#
|
103
111
|
# @example
|
104
112
|
# contantize('my_check') => 'MyCheck'
|
105
|
-
#
|
113
|
+
#
|
106
114
|
# @return [String]
|
107
115
|
def constantize(name)
|
108
116
|
name.to_s.split('_').map(&:capitalize).join
|
data/lib/heartcheck/app.rb
CHANGED
@@ -23,6 +23,7 @@ module Heartcheck
|
|
23
23
|
#
|
24
24
|
# @param app [RackApp] is a rack app where
|
25
25
|
# heartcheck is included.
|
26
|
+
#
|
26
27
|
# @return [void]
|
27
28
|
def initialize(app = nil)
|
28
29
|
@app = app
|
@@ -32,6 +33,7 @@ module Heartcheck
|
|
32
33
|
#
|
33
34
|
# @param env [Hash] is an instance of Hash
|
34
35
|
# that includes CGI-like headers.
|
36
|
+
#
|
35
37
|
# @return [Array] must be an array that contains
|
36
38
|
# - The HTTP response code
|
37
39
|
# - A Hash of headers
|
@@ -50,6 +52,7 @@ module Heartcheck
|
|
50
52
|
# and call the index method
|
51
53
|
#
|
52
54
|
# @param req [Rack::Request] an instance of request
|
55
|
+
#
|
53
56
|
# @return [String] a response body
|
54
57
|
def dispatch_action(req)
|
55
58
|
controller = ROUTE_TO_CONTROLLER[req.path_info]
|
@@ -1,12 +1,39 @@
|
|
1
1
|
module Heartcheck
|
2
2
|
module Checks
|
3
|
+
# Base check that contains the common functionality for chechs
|
3
4
|
class Base
|
4
|
-
|
5
|
-
|
5
|
+
# When it is true the check will work just for `/functional` route.
|
6
|
+
# It should be used to add warning messages that need to verify,
|
7
|
+
# but doesn't break your application.
|
8
|
+
# For example when your async process has more than 3 jobs.
|
9
|
+
#
|
10
|
+
# @return [Boolean] (default: false)
|
11
|
+
attr_accessor :functional
|
6
12
|
alias_method :functional?, :functional
|
13
|
+
|
14
|
+
# When it is true the check will work just for `/dev` route.
|
15
|
+
# you can use it to create some check is not essential/functional for you app.
|
16
|
+
# For example you can execute some performance check.
|
17
|
+
#
|
18
|
+
# @return [Boolean] (default: false)
|
19
|
+
attr_accessor :dev
|
7
20
|
alias_method :dev?, :dev
|
8
21
|
|
9
|
-
#
|
22
|
+
# The name for identify the check in the result page
|
23
|
+
#
|
24
|
+
# @return [String]
|
25
|
+
attr_accessor :name
|
26
|
+
|
27
|
+
# Time that the check has to execute.
|
28
|
+
# If it is 0 the timeout will be disable
|
29
|
+
#
|
30
|
+
# @return [Integer] (default: 0)
|
31
|
+
attr_accessor :timeout
|
32
|
+
|
33
|
+
|
34
|
+
# Create a new instance and set the default values.
|
35
|
+
#
|
36
|
+
# @return [Check]
|
10
37
|
def initialize
|
11
38
|
@dynamic_services = nil
|
12
39
|
@error_proc = nil
|
@@ -19,22 +46,61 @@ module Heartcheck
|
|
19
46
|
@validate_proc = nil
|
20
47
|
end
|
21
48
|
|
49
|
+
# Seter to add a proc to execute when some check fail.
|
50
|
+
#
|
51
|
+
# @return [void]
|
22
52
|
def on_error(&block)
|
23
53
|
@error_proc = block if block_given?
|
24
54
|
end
|
25
55
|
|
56
|
+
# Seter to add a proc to execute to check.
|
57
|
+
#
|
58
|
+
# @yieldparam services [Array<Hash>] services to check
|
59
|
+
# @yieldparam errors [Array<String>] to add error message when check fails
|
60
|
+
#
|
61
|
+
# @example
|
62
|
+
# c.to_validate do |services, errors|
|
63
|
+
# services.each do |service|
|
64
|
+
# errors << "erro message" unless if service[:connection].connected?
|
65
|
+
# end
|
66
|
+
# end
|
67
|
+
#
|
68
|
+
# @return [void]
|
26
69
|
def to_validate(&block)
|
27
70
|
@validate_proc = block if block_given?
|
28
71
|
end
|
29
72
|
|
73
|
+
# It is used to register dynamic services thats need to be evaluate when the checker is running.
|
74
|
+
# This proc need to return an Array.
|
75
|
+
#
|
76
|
+
# @example
|
77
|
+
# register_dynamic_services do
|
78
|
+
# [
|
79
|
+
# { name: 'service name', connection: MyConnection }
|
80
|
+
# ]
|
81
|
+
# end
|
82
|
+
#
|
83
|
+
# @return [void]
|
30
84
|
def register_dynamic_services(&block)
|
31
85
|
@dynamic_services = block if block_given?
|
32
86
|
end
|
33
87
|
|
88
|
+
# It is used to add a service that will use when check run.
|
89
|
+
#
|
90
|
+
# @param service [Hash]
|
91
|
+
#
|
92
|
+
# @example
|
93
|
+
# add_service(name: 'service name', connection: MyConnection)
|
94
|
+
#
|
95
|
+
# @return [void]
|
34
96
|
def add_service(service)
|
35
97
|
@services << service
|
36
98
|
end
|
37
99
|
|
100
|
+
|
101
|
+
# It is used to add a service that will use when check run.
|
102
|
+
#
|
103
|
+
# @return [Array<Hash>]
|
38
104
|
def services
|
39
105
|
if @dynamic_services
|
40
106
|
@services + @dynamic_services.call
|
@@ -43,13 +109,14 @@ module Heartcheck
|
|
43
109
|
end
|
44
110
|
end
|
45
111
|
|
112
|
+
# run the check and return formated erros
|
113
|
+
#
|
114
|
+
# @return [Hash]
|
46
115
|
def check
|
47
116
|
validation
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
Logger.info Oj.dump(hash)
|
52
|
-
hash
|
117
|
+
{ name => { 'status' => (@errors.empty? ? 'ok' : 'error') } }.tap do |response|
|
118
|
+
response[name]['message'] = error_message unless @errors.empty?
|
119
|
+
end
|
53
120
|
end
|
54
121
|
|
55
122
|
def informations
|
@@ -60,6 +127,9 @@ module Heartcheck
|
|
60
127
|
|
61
128
|
private
|
62
129
|
|
130
|
+
# Used to add an error to @erros.
|
131
|
+
#
|
132
|
+
# @return [void]
|
63
133
|
def append_error(*args)
|
64
134
|
if @error_proc
|
65
135
|
@error_proc.call(@errors, *args)
|
@@ -68,6 +138,9 @@ module Heartcheck
|
|
68
138
|
end
|
69
139
|
end
|
70
140
|
|
141
|
+
# run the check
|
142
|
+
#
|
143
|
+
# @return [Array<String>]
|
71
144
|
def validation
|
72
145
|
@errors = []
|
73
146
|
begin
|
@@ -86,16 +159,30 @@ module Heartcheck
|
|
86
159
|
@errors
|
87
160
|
end
|
88
161
|
|
162
|
+
# Get formated error messages for each service after run the check
|
163
|
+
#
|
164
|
+
# @example
|
165
|
+
# @erros = ['some string']
|
166
|
+
# error_message
|
167
|
+
# # => [{type: 'error', message: 'some string'}]
|
168
|
+
#
|
169
|
+
# @return [Array<Hash>]
|
89
170
|
def error_message
|
90
171
|
@errors.map(&format_error)
|
91
172
|
end
|
92
173
|
|
174
|
+
# format the an error message with a format the check need.
|
175
|
+
#
|
176
|
+
# @example
|
177
|
+
# "some string".format_error
|
178
|
+
# # => {type: 'error', message: 'some string'}
|
179
|
+
#
|
180
|
+
# @return [Hash]
|
93
181
|
def format_error
|
94
182
|
lambda do |error|
|
95
183
|
error.is_a?(Hash) ? error : { type: 'error', message: error }
|
96
184
|
end
|
97
185
|
end
|
98
|
-
|
99
186
|
end
|
100
187
|
end
|
101
188
|
end
|
@@ -10,7 +10,7 @@ module Heartcheck
|
|
10
10
|
def validate
|
11
11
|
services.each do |service|
|
12
12
|
if not service[:runtime].eql? installed(service[:file])
|
13
|
-
@errors << "App outdated, check info for
|
13
|
+
@errors << "App outdated, check /monitoring/info for more details!"
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -13,9 +13,13 @@ module Heartcheck
|
|
13
13
|
protected
|
14
14
|
|
15
15
|
def check(who)
|
16
|
-
Oj.dump(Heartcheck
|
17
|
-
|
18
|
-
|
16
|
+
Oj.dump(executor.dispatch(Heartcheck.send("#{who}_checks")))
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def executor
|
22
|
+
Heartcheck::Executors::Base.new
|
19
23
|
end
|
20
24
|
end
|
21
25
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'heartcheck/executors/base'
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Heartcheck
|
2
|
+
module Executors
|
3
|
+
class Base
|
4
|
+
def dispatch(checkers)
|
5
|
+
checkers.map do |checker|
|
6
|
+
started = Time.now
|
7
|
+
checker.check.tap do |checked|
|
8
|
+
checked[:time] = ((Time.now - started) * 1_000.0)
|
9
|
+
Logger.info Oj.dump(checked)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -3,10 +3,10 @@ Heartcheck.setup do |monitor|
|
|
3
3
|
# default value: Logger.new(STDOUT)
|
4
4
|
# monitor.logger = Rails.logger
|
5
5
|
|
6
|
-
#
|
7
|
-
# For each
|
6
|
+
# Checks
|
7
|
+
# For each check you can set the folling options
|
8
8
|
# name: String => root name to show in report page (default: class.name)
|
9
|
-
# functional: Boolean =>
|
9
|
+
# functional: Boolean => When is false your check is essential to your application (default: false)
|
10
10
|
# on_error: Block => to customize the errors (default: nil)
|
11
11
|
# to_validate: Block => to validate the sevices (default: nil)
|
12
12
|
#
|
@@ -27,6 +27,30 @@ Heartcheck.setup do |monitor|
|
|
27
27
|
# end
|
28
28
|
# end
|
29
29
|
# end
|
30
|
+
#
|
31
|
+
# Services
|
32
|
+
# All check can receive a service to check.
|
33
|
+
# For example you can add 2 diferent hosts to check the firewall in the same checker.
|
34
|
+
#
|
35
|
+
# monitor.add :firewall do |c|
|
36
|
+
# c.add_service(host: 'lala.com', port: 80)
|
37
|
+
# c.add_service(host: 'popo.com', port: 80)
|
38
|
+
# end
|
39
|
+
#
|
40
|
+
# Take atention because we evaluate the services when ruby load the configuration file.
|
41
|
+
# But there's a way to send a service that will evaluate when the test will run. To use with thats way
|
42
|
+
# you need to register a service with `register_dynamic_services`.
|
43
|
+
# http://www.rubydoc.info/github/locaweb/heartcheck/Heartcheck/Checks/Base#register_dynamic_services-instance_method
|
44
|
+
#
|
45
|
+
# monitor.add :firewall do |c|
|
46
|
+
# c.register_dynamic_services do
|
47
|
+
# [
|
48
|
+
# { host: 'lala.com', port: 80 },
|
49
|
+
# { host: 'popo.com', port: 80 }
|
50
|
+
# ]
|
51
|
+
# end
|
52
|
+
# end
|
53
|
+
|
30
54
|
|
31
55
|
# Firewall
|
32
56
|
# check with telnet if the firewall is open to conect to the service
|
data/lib/heartcheck/logger.rb
CHANGED
data/lib/heartcheck/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: heartcheck
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Locaweb
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -153,7 +153,7 @@ dependencies:
|
|
153
153
|
version: 0.8.0
|
154
154
|
- - ">="
|
155
155
|
- !ruby/object:Gem::Version
|
156
|
-
version: 0.8.7
|
156
|
+
version: 0.8.7.6
|
157
157
|
type: :development
|
158
158
|
prerelease: false
|
159
159
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -163,27 +163,7 @@ dependencies:
|
|
163
163
|
version: 0.8.0
|
164
164
|
- - ">="
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version: 0.8.7
|
167
|
-
- !ruby/object:Gem::Dependency
|
168
|
-
name: redcarpet
|
169
|
-
requirement: !ruby/object:Gem::Requirement
|
170
|
-
requirements:
|
171
|
-
- - "~>"
|
172
|
-
- !ruby/object:Gem::Version
|
173
|
-
version: 3.2.0
|
174
|
-
- - ">="
|
175
|
-
- !ruby/object:Gem::Version
|
176
|
-
version: 3.2.2
|
177
|
-
type: :development
|
178
|
-
prerelease: false
|
179
|
-
version_requirements: !ruby/object:Gem::Requirement
|
180
|
-
requirements:
|
181
|
-
- - "~>"
|
182
|
-
- !ruby/object:Gem::Version
|
183
|
-
version: 3.2.0
|
184
|
-
- - ">="
|
185
|
-
- !ruby/object:Gem::Version
|
186
|
-
version: 3.2.2
|
166
|
+
version: 0.8.7.6
|
187
167
|
description: A simple way to check your app heart.
|
188
168
|
email:
|
189
169
|
- desenvolvedores@locaweb.com.br
|
@@ -192,7 +172,20 @@ executables:
|
|
192
172
|
extensions: []
|
193
173
|
extra_rdoc_files: []
|
194
174
|
files:
|
195
|
-
-
|
175
|
+
- ".gitignore"
|
176
|
+
- ".rspec"
|
177
|
+
- ".rubocop.yml"
|
178
|
+
- ".travis.yml"
|
179
|
+
- CHANGELOG
|
180
|
+
- Gemfile
|
181
|
+
- Gemfile.lock
|
182
|
+
- LICENSE.txt
|
183
|
+
- README.md
|
184
|
+
- Rakefile
|
185
|
+
- bin/console
|
186
|
+
- bin/rspec
|
187
|
+
- exe/heartcheck
|
188
|
+
- heartcheck.gemspec
|
196
189
|
- lib/heartcheck.rb
|
197
190
|
- lib/heartcheck/app.rb
|
198
191
|
- lib/heartcheck/checks.rb
|
@@ -209,6 +202,8 @@ files:
|
|
209
202
|
- lib/heartcheck/errors.rb
|
210
203
|
- lib/heartcheck/errors/routing_error.rb
|
211
204
|
- lib/heartcheck/errors/warning.rb
|
205
|
+
- lib/heartcheck/executors.rb
|
206
|
+
- lib/heartcheck/executors/base.rb
|
212
207
|
- lib/heartcheck/generators.rb
|
213
208
|
- lib/heartcheck/generators/generator.rb
|
214
209
|
- lib/heartcheck/generators/templates/config.rb
|