philae 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/philae/docker_probe.rb +25 -0
- data/lib/philae/http_probe.rb +30 -0
- data/lib/philae/mongo_probe.rb +23 -0
- data/lib/philae/philae_probe.rb +33 -0
- data/lib/philae/prober.rb +26 -0
- data/lib/philae.rb +9 -0
- metadata +92 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3dbb29e017bdc7e8f163b7d791f58f372e5f57d8
|
4
|
+
data.tar.gz: 317cbad8caa16777d1bb996dd5667c336dff1508
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: afb9de7a624f945cbb3f276819d74d2ed20a98c7f6a7fbf3c9966ab0e082e3c72608fd593fcac44a81ad68f4d297925a1e16e1402b18acd5057cecd26a79654d
|
7
|
+
data.tar.gz: 6e8a58dbeab4019bad6604e638873802c224c8e55958b2932146baeac5f11b8c0a5ee5f2cdcf2a86310710b9c105aaecc2e727a3df4478a3822262668bac96b3
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'docker'
|
2
|
+
|
3
|
+
module Philae
|
4
|
+
class DockerProbe
|
5
|
+
attr_reader :name
|
6
|
+
|
7
|
+
def initialize(name, endpoint = '/var/run/docker.sock', options = nil)
|
8
|
+
@name = name
|
9
|
+
@endpoint = endpoint
|
10
|
+
@docker_options = options
|
11
|
+
end
|
12
|
+
|
13
|
+
def check
|
14
|
+
Docker.url = @endpoint
|
15
|
+
Docker.options = @docker_options unless @docker_options.nil? # <3 Etienne
|
16
|
+
begin
|
17
|
+
Docker::Container.all
|
18
|
+
rescue
|
19
|
+
return false
|
20
|
+
end
|
21
|
+
|
22
|
+
true
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
|
3
|
+
module Philae
|
4
|
+
class HttpProbe
|
5
|
+
attr_reader :name
|
6
|
+
|
7
|
+
def initialize(name, uri, username = nil, password = nil)
|
8
|
+
@name = name
|
9
|
+
@uri = uri
|
10
|
+
@username = username
|
11
|
+
@password = password
|
12
|
+
end
|
13
|
+
|
14
|
+
def check
|
15
|
+
begin
|
16
|
+
uri = URI(@uri)
|
17
|
+
req = Net::HTTP::Get.new(uri)
|
18
|
+
req.basic_auth @username, @password if !@username.nil? || !@password.nil?
|
19
|
+
resp = Net::HTTP.start(uri.hostname, uri.port) do |http|
|
20
|
+
http.request(req)
|
21
|
+
end
|
22
|
+
|
23
|
+
return false if resp.code.to_s[0] != '2' && resp.code.to_s[0] != '3'
|
24
|
+
rescue
|
25
|
+
return false
|
26
|
+
end
|
27
|
+
true
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'mongo'
|
2
|
+
|
3
|
+
module Philae
|
4
|
+
class MongoProbe
|
5
|
+
attr_reader :name
|
6
|
+
|
7
|
+
def initialize(name, uri)
|
8
|
+
@name = name
|
9
|
+
@uri = uri
|
10
|
+
end
|
11
|
+
|
12
|
+
def check
|
13
|
+
begin
|
14
|
+
client = Mongo::Client.new(@uri)
|
15
|
+
db = client.datbase
|
16
|
+
db.collection_names
|
17
|
+
rescue
|
18
|
+
return false
|
19
|
+
end
|
20
|
+
true
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module Philae
|
5
|
+
class PhilaeProbe
|
6
|
+
attr_accessor :name
|
7
|
+
|
8
|
+
def initialize(name, uri, username = nil, password = nil)
|
9
|
+
@name = name
|
10
|
+
@uri = uri
|
11
|
+
@username = username
|
12
|
+
@password = password
|
13
|
+
end
|
14
|
+
|
15
|
+
def check
|
16
|
+
begin
|
17
|
+
uri = URI(@uri)
|
18
|
+
req = Net::HTTP::Get.new(uri)
|
19
|
+
req.basic_auth @username, @password if !@username.nil? || !@password.nil?
|
20
|
+
resp = Net::HTTP.start(uri.hostname, uri.port) do |http|
|
21
|
+
http.request(req)
|
22
|
+
end
|
23
|
+
|
24
|
+
return false if resp.code.to_s[0] != '2' && resp.code.to_s[0] != '3'
|
25
|
+
|
26
|
+
status = JSON.parse(resp.body)
|
27
|
+
return status['healthy']
|
28
|
+
rescue
|
29
|
+
return false
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Philae
|
2
|
+
class Prober
|
3
|
+
def initialize
|
4
|
+
@probes = []
|
5
|
+
end
|
6
|
+
|
7
|
+
def add_probe(probe)
|
8
|
+
@probes << probe
|
9
|
+
end
|
10
|
+
|
11
|
+
def check
|
12
|
+
probes_status = @probes.map do |probe|
|
13
|
+
{ name: probe.name, healthy: probe.check }
|
14
|
+
end
|
15
|
+
|
16
|
+
global = probes_status.all? do |probe|
|
17
|
+
probe[:healthy]
|
18
|
+
end
|
19
|
+
|
20
|
+
{
|
21
|
+
healthy: global,
|
22
|
+
probes: probes_status
|
23
|
+
}
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/philae.rb
ADDED
metadata
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: philae
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- leo@scalingo.com
|
8
|
+
- john@scalingo.com
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2017-04-24 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: docker-api
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '1.33'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '1.33'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: mongo
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '2.4'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '2.4'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: json
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '2.1'
|
49
|
+
type: :runtime
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '2.1'
|
56
|
+
description:
|
57
|
+
email: hello@scalingo.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- lib/philae.rb
|
63
|
+
- lib/philae/docker_probe.rb
|
64
|
+
- lib/philae/http_probe.rb
|
65
|
+
- lib/philae/mongo_probe.rb
|
66
|
+
- lib/philae/philae_probe.rb
|
67
|
+
- lib/philae/prober.rb
|
68
|
+
homepage: https://scalingo.com
|
69
|
+
licenses:
|
70
|
+
- BSD-3-Clause
|
71
|
+
metadata: {}
|
72
|
+
post_install_message:
|
73
|
+
rdoc_options: []
|
74
|
+
require_paths:
|
75
|
+
- lib
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
requirements: []
|
87
|
+
rubyforge_project:
|
88
|
+
rubygems_version: 2.5.2
|
89
|
+
signing_key:
|
90
|
+
specification_version: 4
|
91
|
+
summary: Provide an healthcheck api
|
92
|
+
test_files: []
|