hcheck 0.1.0 → 0.1.1
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/.travis.yml +9 -2
- data/Gemfile.lock +1 -1
- data/README.md +3 -2
- data/hcheck.gemspec +1 -1
- data/lib/hcheck/checks/memcached.rb +0 -4
- data/lib/hcheck/checks/mongodb.rb +0 -4
- data/lib/hcheck/checks/mysql.rb +0 -4
- data/lib/hcheck/checks/ping.rb +10 -9
- data/lib/hcheck/checks/postgresql.rb +0 -4
- data/lib/hcheck/checks/rabbitmq.rb +0 -10
- data/lib/hcheck/checks/redis.rb +0 -4
- data/lib/hcheck/configuration/service.rb +9 -1
- data/lib/hcheck/errors.rb +10 -0
- data/lib/hcheck/helper.rb +1 -1
- data/lib/hcheck/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: 4e3d277ec5fd7cb5d49761ed2437b79cbe60c3c2
|
4
|
+
data.tar.gz: bfcc780533bdef656e295a4211331f823ee77339
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f58c28e881cb5de5c7520a846e911fcbf2d721fd77913bb38923725c94be5ae922156cef76a16bf05ee175f104f41919f2f9197ae3c731eea3fe12d1c23a7223
|
7
|
+
data.tar.gz: b0fd9d9d065454d8723a5fc82f6f78cb4a6bbb5c047bebee69c7fc917e36e26f474913f8689d627e0813e27fd502746fcbfa84c394553009f1d0f5b6b3f1fbd3
|
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# Hcheck
|
2
|
+
[](https://travis-ci.com/cloudfactory/hcheck)
|
2
3
|
|
3
4
|
Configuration driven health checker for ruby apps. Can be mounted or booted as standalone app.
|
4
5
|
|
@@ -112,8 +113,8 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
112
113
|
## Todo
|
113
114
|
|
114
115
|
Travis CI Integrations
|
115
|
-
- Github PR status
|
116
|
-
- Continuous Integration
|
116
|
+
- ~~Github PR status~~
|
117
|
+
- ~~Continuous Integration~~
|
117
118
|
- Continuous release to RubyGems
|
118
119
|
|
119
120
|
## Contributing
|
data/hcheck.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
19
19
|
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
20
20
|
if spec.respond_to?(:metadata)
|
21
|
-
spec.metadata['allowed_push_host'] =
|
21
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
22
22
|
else
|
23
23
|
raise 'RubyGems 2.0 or newer is required to protect against ' \
|
24
24
|
'public gem pushes.'
|
@@ -8,10 +8,6 @@ module Hcheck
|
|
8
8
|
def status(config)
|
9
9
|
client = Dalli::Client.new(config.delete(:url), config)
|
10
10
|
client.get('_')
|
11
|
-
'ok'
|
12
|
-
rescue Dalli::RingError => e
|
13
|
-
Hcheck.logger.error "[HCheck] Memcached::Error::NoServerAvailable #{e.message}"
|
14
|
-
'bad'
|
15
11
|
end
|
16
12
|
|
17
13
|
def self.included(_base)
|
@@ -11,10 +11,6 @@ module Hcheck
|
|
11
11
|
client = Mongo::Client.new(hosts, mongo_config.merge(server_selection_timeout: hosts.count * 2))
|
12
12
|
client.database_names
|
13
13
|
client.close
|
14
|
-
'ok'
|
15
|
-
rescue Mongo::Error::NoServerAvailable => e
|
16
|
-
Hcheck.logger.error "[HCheck] Mongo::Error::NoServerAvailable #{e.message}"
|
17
|
-
'bad'
|
18
14
|
end
|
19
15
|
|
20
16
|
def self.included(_base)
|
data/lib/hcheck/checks/mysql.rb
CHANGED
data/lib/hcheck/checks/ping.rb
CHANGED
@@ -10,15 +10,11 @@ module Hcheck
|
|
10
10
|
url = URI.parse(config[:url])
|
11
11
|
request = build_request(url)
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
end
|
19
|
-
rescue Net::ReadTimeout, Errno::ECONNREFUSED => e
|
20
|
-
Hcheck.logger.error "[HCheck] Ping Fail #{e.message}"
|
21
|
-
'bad'
|
13
|
+
res = request.request_head(url.path)
|
14
|
+
|
15
|
+
ok_responses = [Net::HTTPSuccess, Net::HTTPInformation, Net::HTTPMovedPermanently]
|
16
|
+
|
17
|
+
fail_with(res, url) unless ok_responses.include?(res.class)
|
22
18
|
end
|
23
19
|
|
24
20
|
def self.included(_base)
|
@@ -33,6 +29,11 @@ module Hcheck
|
|
33
29
|
url.path = '/' if url.path.empty?
|
34
30
|
req
|
35
31
|
end
|
32
|
+
|
33
|
+
def fail_with(response, url)
|
34
|
+
raise Hcheck::Errors::HTTPError,
|
35
|
+
[response.class, response.code, response.message].join(' ') + " from #{url}"
|
36
|
+
end
|
36
37
|
end
|
37
38
|
end
|
38
39
|
end
|
@@ -10,10 +10,6 @@ module Hcheck
|
|
10
10
|
config[:dbname] = config.delete(:database) if config[:database]
|
11
11
|
|
12
12
|
PG::Connection.new(config).close
|
13
|
-
'ok'
|
14
|
-
rescue PG::ConnectionBad => e
|
15
|
-
Hcheck.logger.error "[HCheck] PG::ConnectionBad #{e.message}"
|
16
|
-
'bad'
|
17
13
|
end
|
18
14
|
|
19
15
|
def self.included(_base)
|
@@ -9,16 +9,6 @@ module Hcheck
|
|
9
9
|
connection = Bunny.new(config)
|
10
10
|
connection.start
|
11
11
|
connection.close
|
12
|
-
'ok'
|
13
|
-
rescue Bunny::TCPConnectionFailed,
|
14
|
-
Bunny::TCPConnectionFailedForAllHosts,
|
15
|
-
Bunny::NetworkFailure,
|
16
|
-
Bunny::AuthenticationFailureError,
|
17
|
-
Bunny::PossibleAuthenticationFailureError,
|
18
|
-
AMQ::Protocol::EmptyResponseError => e
|
19
|
-
|
20
|
-
Hcheck.logger.error "[HCheck] Bunny::Error #{e.message}"
|
21
|
-
'bad'
|
22
12
|
end
|
23
13
|
|
24
14
|
def self.included(_base)
|
data/lib/hcheck/checks/redis.rb
CHANGED
@@ -9,10 +9,6 @@ module Hcheck
|
|
9
9
|
config[:sentinels] = config[:sentinels].map(&:symbolize_keys) if config[:sentinels]
|
10
10
|
|
11
11
|
::Redis.new(config).ping
|
12
|
-
'ok'
|
13
|
-
rescue ::Redis::CannotConnectError => e
|
14
|
-
Hcheck.logger.error "[HCheck] Redis server unavailable #{e.message}"
|
15
|
-
'bad'
|
16
12
|
end
|
17
13
|
|
18
14
|
def self.included(_base)
|
@@ -30,12 +30,20 @@ module Hcheck
|
|
30
30
|
{
|
31
31
|
name: @name,
|
32
32
|
desc: @check,
|
33
|
-
status: @check_not_available ? NOT_IMPLEMENTED_MSG :
|
33
|
+
status: @check_not_available ? NOT_IMPLEMENTED_MSG : check_status
|
34
34
|
}
|
35
35
|
end
|
36
36
|
|
37
37
|
private
|
38
38
|
|
39
|
+
def check_status
|
40
|
+
status(@options)
|
41
|
+
'ok'
|
42
|
+
rescue StandardError => e
|
43
|
+
Hcheck.logger.error "[HCheck] #{e.class.name} #{e.message}"
|
44
|
+
'bad'
|
45
|
+
end
|
46
|
+
|
39
47
|
def load_mod
|
40
48
|
Hcheck::Checks.const_get(@name.capitalize)
|
41
49
|
rescue NameError
|
data/lib/hcheck/errors.rb
CHANGED
@@ -13,14 +13,17 @@ module Hcheck
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
+
# Invalid auth token, when hcheck secure enabled
|
16
17
|
class InvalidAuthentication < HcheckError
|
17
18
|
MSG = 'Invalid authenticity token!'
|
18
19
|
end
|
19
20
|
|
21
|
+
# Incomplete auth setup, auth token not setup, when hcheck secure enabled
|
20
22
|
class IncompleteAuthSetup < HcheckError
|
21
23
|
MSG = 'Incomplete auth setup in HCheck server'
|
22
24
|
end
|
23
25
|
|
26
|
+
# Configuration related error
|
24
27
|
class ConfigurationError < HcheckError
|
25
28
|
MSG = 'Hcheck configuration cannot not be found or read'
|
26
29
|
|
@@ -28,5 +31,12 @@ module Hcheck
|
|
28
31
|
super("#{MSG}\n#{err.class}\n#{err.message}")
|
29
32
|
end
|
30
33
|
end
|
34
|
+
|
35
|
+
# HTTP related error
|
36
|
+
class HTTPError < HcheckError
|
37
|
+
def initialize(msg)
|
38
|
+
super("Couldn't get a successful response code. #{msg}")
|
39
|
+
end
|
40
|
+
end
|
31
41
|
end
|
32
42
|
end
|
data/lib/hcheck/helper.rb
CHANGED
data/lib/hcheck/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hcheck
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rohit Joshi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-09-
|
11
|
+
date: 2018-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: haml
|