apphealth 1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +41 -0
- data/LICENSE +22 -0
- data/README.md +42 -0
- data/Rakefile +1 -0
- data/apphealth.gemspec +27 -0
- data/bin/apphealth +21 -0
- data/fixtures/domain.com.yml +4 -0
- data/fixtures/domain.net.yml +4 -0
- data/lib/apphealth.rb +9 -0
- data/lib/apphealth/checker.rb +27 -0
- data/lib/apphealth/config.rb +39 -0
- data/lib/apphealth/server.rb +44 -0
- data/lib/apphealth/version.rb +3 -0
- data/spec/checker_spec.rb +62 -0
- data/spec/config_spec.rb +84 -0
- data/spec/server_spec.rb +87 -0
- data/spec/spec_helper.rb +10 -0
- metadata +166 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1ede9f98e59fc2fcf11d237918eaa8c178d5f97b
|
4
|
+
data.tar.gz: 05687ba3321f9e02459fdfee9c25ec08af260b25
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a0f1ef3581e81f6eb4e5ac2b51f50f5753846f9b360a2aa89c36c219e52eb8de397427dbf4f877d54b70d41a47d79373e054a9654b606f5b1fe8edc2fc1e4714
|
7
|
+
data.tar.gz: 33e1b7aed7180f05c53cec98640d99d8d59b0d8ecd17606397145830a27e5f08329a369e36013f0d594b5bd005d3c5ccb8ff89d3a8ce07661150c93926bbc414
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
apphealth (0.1)
|
5
|
+
colored
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
colored (1.2)
|
11
|
+
columnize (0.3.6)
|
12
|
+
debugger (1.6.2)
|
13
|
+
columnize (>= 0.3.1)
|
14
|
+
debugger-linecache (~> 1.2.0)
|
15
|
+
debugger-ruby_core_source (~> 1.2.3)
|
16
|
+
debugger-linecache (1.2.0)
|
17
|
+
debugger-ruby_core_source (1.2.3)
|
18
|
+
diff-lcs (1.2.4)
|
19
|
+
fakefs (0.4.3)
|
20
|
+
fakeweb (1.3.0)
|
21
|
+
rake (10.1.0)
|
22
|
+
rspec (2.14.1)
|
23
|
+
rspec-core (~> 2.14.0)
|
24
|
+
rspec-expectations (~> 2.14.0)
|
25
|
+
rspec-mocks (~> 2.14.0)
|
26
|
+
rspec-core (2.14.7)
|
27
|
+
rspec-expectations (2.14.3)
|
28
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
29
|
+
rspec-mocks (2.14.4)
|
30
|
+
|
31
|
+
PLATFORMS
|
32
|
+
ruby
|
33
|
+
|
34
|
+
DEPENDENCIES
|
35
|
+
apphealth!
|
36
|
+
bundler (~> 1.3)
|
37
|
+
debugger
|
38
|
+
fakefs
|
39
|
+
fakeweb (~> 1.3)
|
40
|
+
rake
|
41
|
+
rspec (~> 2.6)
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Dennis Paagman
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# AppHealth
|
2
|
+
[![Build Status](https://travis-ci.org/djfpaagman/apphealth.png?branch=master)](https://travis-ci.org/djfpaagman/apphealth)
|
3
|
+
|
4
|
+
AppHealth checks the response for a specific URL on each app server. It does so by overwriting the Host header to the original hostname to trick
|
5
|
+
the app server in serving the correct content. It also speeds up the check by creating a seperate thread for each request and outputs to stdout.
|
6
|
+
|
7
|
+
![Example](http://springest-monosnap.s3-website-eu-west-1.amazonaws.com/tn2rlqi0ibwfqgr00ahg.png)
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
AppHealth checks for a `.apphealth.yml` in either the directory your in or in your home directory. Create this file on a per project basis or just put it in your home dir as a default.
|
11
|
+
|
12
|
+
The structure of the confg file needs to be as followed:
|
13
|
+
|
14
|
+
```yaml
|
15
|
+
default_url: http://domain.com/foo123
|
16
|
+
servers:
|
17
|
+
- server01.domain.com
|
18
|
+
- server02.domain.com
|
19
|
+
```
|
20
|
+
|
21
|
+
* `default_url` will be checked when no parameters are supplied to the command
|
22
|
+
* `servers` is an array of servers that are requested. It can be of any size.
|
23
|
+
|
24
|
+
After creating your config file you can check the app server by running the following command:
|
25
|
+
|
26
|
+
``apphealth [url]`
|
27
|
+
|
28
|
+
* `url` is an optional url to check, if none is given it will check the `default_url` from the config.
|
29
|
+
|
30
|
+
## Gotchas
|
31
|
+
For this script to work your app servers have to be directly reachable over http(s). I recommend using a VPN connection and only allowing direct access through the VPN. This way you won't expose your app servers to the whole internet directly.
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
1. Fork it
|
36
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
37
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
38
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
39
|
+
5. Create new Pull Request
|
40
|
+
|
41
|
+
## License
|
42
|
+
AppHealth is released under the [MIT License](LICENSE).
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/apphealth.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'apphealth/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "apphealth"
|
7
|
+
spec.version = AppHealth::VERSION
|
8
|
+
spec.authors = ["Dennis Paagman"]
|
9
|
+
spec.email = ["dennispaagman@gmail.com"]
|
10
|
+
spec.summary = %q{AppHealth checks the response for a specific URL on each app server}
|
11
|
+
spec.description = spec.summary
|
12
|
+
spec.homepage = "https://github.com/djfpaagman/apphealth"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files`.split($/)
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
21
|
+
spec.add_development_dependency "rake"
|
22
|
+
spec.add_development_dependency "rspec", "~> 2.6"
|
23
|
+
spec.add_development_dependency "fakeweb", ["~> 1.3"]
|
24
|
+
spec.add_development_dependency "fakefs"
|
25
|
+
spec.add_development_dependency "debugger"
|
26
|
+
spec.add_dependency 'colored'
|
27
|
+
end
|
data/bin/apphealth
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'apphealth'
|
4
|
+
require 'colored'
|
5
|
+
|
6
|
+
check = AppHealth::Checker.new(ARGV[0])
|
7
|
+
|
8
|
+
# each number maps to a class of http responses. For example 2 for 2xx responses.
|
9
|
+
color_map = {
|
10
|
+
'2' => 'green',
|
11
|
+
'3' => 'orange',
|
12
|
+
'4' => 'red',
|
13
|
+
'5' => 'red',
|
14
|
+
}
|
15
|
+
|
16
|
+
puts "Checking #{check.servers.count} servers for #{check.uri}:"
|
17
|
+
check.run.servers.each do |server|
|
18
|
+
color = color_map[server.code.chars.first]
|
19
|
+
|
20
|
+
puts "#{server.host}: #{server.code} #{server.message} #{server.duration}ms".send(color)
|
21
|
+
end
|
data/lib/apphealth.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
module AppHealth
|
2
|
+
class Checker
|
3
|
+
attr_accessor :uri, :threads, :servers
|
4
|
+
|
5
|
+
def initialize(url = nil)
|
6
|
+
url ||= Config.default_url
|
7
|
+
|
8
|
+
@uri = URI.parse(url)
|
9
|
+
@threads = []
|
10
|
+
@servers = Config.servers.map do |server|
|
11
|
+
Server.new(server)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def run
|
16
|
+
servers.select(&:unchecked?).each do |server|
|
17
|
+
threads << Thread.new do
|
18
|
+
server.check(uri)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
threads.each(&:join)
|
23
|
+
|
24
|
+
self
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module AppHealth
|
4
|
+
class ConfigNotFound < Exception; end
|
5
|
+
|
6
|
+
class Config
|
7
|
+
FILE_NAME = '.apphealth.yml'
|
8
|
+
|
9
|
+
def self.servers
|
10
|
+
self.config['servers']
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.default_url
|
14
|
+
self.config['default_url']
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.config_file
|
18
|
+
self.current_dir_file || self.home_dir_file
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.config
|
22
|
+
raise ConfigNotFound, 'Config file not found' unless self.config_file
|
23
|
+
|
24
|
+
@config ||= YAML.load_file(self.config_file)
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.home_dir_file
|
28
|
+
File.open(File.join(Dir.home, FILE_NAME), 'r')
|
29
|
+
rescue Errno::ENOENT
|
30
|
+
nil
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.current_dir_file
|
34
|
+
File.open(File.join(__dir__, FILE_NAME), 'r')
|
35
|
+
rescue Errno::ENOENT
|
36
|
+
nil
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module AppHealth
|
2
|
+
class Server
|
3
|
+
attr_accessor :host, :message, :duration, :checked, :code
|
4
|
+
|
5
|
+
def initialize(host)
|
6
|
+
@host = host
|
7
|
+
@checked = false
|
8
|
+
@message = nil
|
9
|
+
@code = nil
|
10
|
+
@duration = nil
|
11
|
+
end
|
12
|
+
|
13
|
+
def unchecked?
|
14
|
+
@checked == false
|
15
|
+
end
|
16
|
+
|
17
|
+
def check(uri)
|
18
|
+
return self if checked
|
19
|
+
|
20
|
+
benchmark = Benchmark.measure do
|
21
|
+
request = make_request(uri)
|
22
|
+
|
23
|
+
@code = request.code
|
24
|
+
@message = request.message
|
25
|
+
end
|
26
|
+
|
27
|
+
@duration = (benchmark.real*1000).round
|
28
|
+
@checked = true
|
29
|
+
|
30
|
+
self
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
def make_request(uri)
|
35
|
+
Net::HTTP.start(host) do |http|
|
36
|
+
uri.path = "/" if uri.path == ""
|
37
|
+
request = Net::HTTP::Get.new(uri.path)
|
38
|
+
request['Host'] = uri.host
|
39
|
+
|
40
|
+
http.request(request)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe AppHealth::Checker do
|
4
|
+
before(:each) do
|
5
|
+
AppHealth::Config.stub(:config_file).and_return do
|
6
|
+
File.open(File.join('fixtures', 'domain.com.yml'), 'r')
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '.new' do
|
11
|
+
context 'without argument' do
|
12
|
+
it 'loads default url' do
|
13
|
+
|
14
|
+
expect(AppHealth::Checker.new.uri).to eq URI.parse("http://domain.com/foo123")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'with argument' do
|
19
|
+
it 'loads that url' do
|
20
|
+
domain = 'http://domain.com'
|
21
|
+
|
22
|
+
expect(AppHealth::Checker.new(domain).uri).to eq URI.parse(domain)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'sets up threads array' do
|
27
|
+
expect(AppHealth::Checker.new.threads).to be_kind_of(Array)
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'loads servers' do
|
31
|
+
expect(AppHealth::Checker.new.servers.size).to eq 2
|
32
|
+
|
33
|
+
AppHealth::Checker.new.servers.each do |server|
|
34
|
+
expect(server).to be_kind_of AppHealth::Server
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#run' do
|
40
|
+
context 'checks all servers' do
|
41
|
+
FakeWeb.register_uri(:get, "http://server01.domain.com/foo123",
|
42
|
+
status: ["200", "OK"])
|
43
|
+
FakeWeb.register_uri(:get, "http://server02.domain.com/foo123",
|
44
|
+
status: ["200", "OK"])
|
45
|
+
|
46
|
+
it 'runs in threads' do
|
47
|
+
checker = AppHealth::Checker.new.run
|
48
|
+
expect(checker.threads.size).to eq 2
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'checked the servers' do
|
52
|
+
checker = AppHealth::Checker.new.run
|
53
|
+
expect(checker.servers.map(&:checked)).to eq [true, true]
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'is all fine' do
|
57
|
+
checker = AppHealth::Checker.new.run
|
58
|
+
expect(checker.servers.map(&:code)).to eq ['200', '200']
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
data/spec/config_spec.rb
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe AppHealth::Config do
|
4
|
+
config_file_com = File.open(File.join('fixtures', 'domain.com.yml'), 'r')
|
5
|
+
config_file_net = File.open(File.join('fixtures', 'domain.net.yml'), 'r')
|
6
|
+
config_com = YAML.load_file(config_file_com)
|
7
|
+
|
8
|
+
context '.home_dir_file' do
|
9
|
+
it 'returns the file when the it exists' do
|
10
|
+
File.stub(:open).and_return(config_file_com)
|
11
|
+
|
12
|
+
expect(AppHealth::Config.home_dir_file).to be_kind_of File
|
13
|
+
expect(AppHealth::Config.home_dir_file).to eq config_file_com
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'returns nil when it doesnt exist' do
|
17
|
+
File.stub(:open).and_raise(Errno::ENOENT)
|
18
|
+
|
19
|
+
expect(AppHealth::Config.home_dir_file).to eq nil
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context '.current_dir_file' do
|
24
|
+
it 'returns the file when the it exists' do
|
25
|
+
File.stub(:open).and_return(config_file_com)
|
26
|
+
|
27
|
+
expect(AppHealth::Config.current_dir_file).to be_kind_of File
|
28
|
+
expect(AppHealth::Config.current_dir_file).to eq config_file_com
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'returns nil when it doesnt exist' do
|
32
|
+
File.stub(:open).and_raise(Errno::ENOENT)
|
33
|
+
|
34
|
+
expect(AppHealth::Config.current_dir_file).to eq nil
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context '.config_file' do
|
39
|
+
before do
|
40
|
+
AppHealth::Config.stub(:home_dir_file).and_return(config_file_net)
|
41
|
+
AppHealth::Config.stub(:current_dir_file).and_return(config_file_com)
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'prefers .current_dir_file over .home_dir_file' do
|
45
|
+
expect(AppHealth::Config.config_file).to eq config_file_com
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'uses .home_dir_file when .current_dir_file doesnt exist' do
|
49
|
+
AppHealth::Config.stub(:current_dir_file).and_return(nil)
|
50
|
+
|
51
|
+
expect(AppHealth::Config.config_file).to eq config_file_net
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context '.config' do
|
56
|
+
it 'throws ConfigNotFound if no config file found' do
|
57
|
+
AppHealth::Config.stub(:config_file).and_return(nil)
|
58
|
+
|
59
|
+
expect { AppHealth::Config.config }.to raise_error(AppHealth::ConfigNotFound)
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'parses yml config' do
|
63
|
+
AppHealth::Config.stub(:config_file).and_return(config_file_com)
|
64
|
+
|
65
|
+
expect(AppHealth::Config.config).to eq config_com
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context '.servers' do
|
70
|
+
it 'returns servers from config file' do
|
71
|
+
AppHealth::Config.stub(:config).and_return(config_com)
|
72
|
+
|
73
|
+
expect(AppHealth::Config.servers).to eq ["server01.domain.com", "server02.domain.com"]
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
context '.default_url' do
|
78
|
+
it 'returns default url from config file' do
|
79
|
+
AppHealth::Config.stub(:config).and_return(config_com)
|
80
|
+
|
81
|
+
expect(AppHealth::Config.default_url).to eq 'http://domain.com/foo123'
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
data/spec/server_spec.rb
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe AppHealth::Server do
|
4
|
+
describe '.new' do
|
5
|
+
it 'requires a host' do
|
6
|
+
expect { AppHealth::Server.new }.to raise_error
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '#unchecked?' do
|
11
|
+
server = AppHealth::Server.new('foo.bar.com')
|
12
|
+
|
13
|
+
it 'is true if checked if false' do
|
14
|
+
expect(server.unchecked?).to eq true
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'is false if checked is true' do
|
18
|
+
server.checked = true
|
19
|
+
|
20
|
+
expect(server.unchecked?).to eq false
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#check' do
|
25
|
+
it 'requires an uri' do
|
26
|
+
expect { AppHealth::Server.new('foo.bar.com').check }.to raise_error
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'with valid uri' do
|
30
|
+
context 'and 200 response' do
|
31
|
+
FakeWeb.register_uri(:get, "http://server01.domain.com/im_fine",
|
32
|
+
status: ["200", "OK"])
|
33
|
+
|
34
|
+
uri = URI.parse('http://domain.com/im_fine')
|
35
|
+
request = AppHealth::Server.new('server01.domain.com').check(uri)
|
36
|
+
|
37
|
+
it 'sets checked' do
|
38
|
+
expect(request.checked).to eq true
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'times request' do
|
42
|
+
expect(request.duration).not_to eq nil
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'sets message' do
|
46
|
+
expect(request.message).to eq 'OK'
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'sets code' do
|
50
|
+
expect(request.code).to eq '200'
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'and 404 response' do
|
56
|
+
FakeWeb.register_uri(:get, "http://server01.domain.com/non_existing",
|
57
|
+
status: ["404", "Not Found"])
|
58
|
+
|
59
|
+
uri = URI.parse('http://domain.com/non_existing')
|
60
|
+
request = AppHealth::Server.new('server01.domain.com').check(uri)
|
61
|
+
|
62
|
+
it 'sets message' do
|
63
|
+
expect(request.message).to eq 'Not Found'
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'sets code' do
|
67
|
+
expect(request.code).to eq '404'
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
context 'and 500 response' do
|
72
|
+
FakeWeb.register_uri(:get, "http://server01.domain.com/error",
|
73
|
+
status: ["500", "Internal Server Error"])
|
74
|
+
|
75
|
+
uri = URI.parse('http://domain.com/error')
|
76
|
+
request = AppHealth::Server.new('server01.domain.com').check(uri)
|
77
|
+
|
78
|
+
it 'sets message' do
|
79
|
+
expect(request.message).to eq 'Internal Server Error'
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'sets code' do
|
83
|
+
expect(request.code).to eq '500'
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,166 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: apphealth
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '1.0'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dennis Paagman
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-11-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.6'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.6'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: fakeweb
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.3'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.3'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: fakefs
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: debugger
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: colored
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: AppHealth checks the response for a specific URL on each app server
|
112
|
+
email:
|
113
|
+
- dennispaagman@gmail.com
|
114
|
+
executables:
|
115
|
+
- apphealth
|
116
|
+
extensions: []
|
117
|
+
extra_rdoc_files: []
|
118
|
+
files:
|
119
|
+
- .travis.yml
|
120
|
+
- Gemfile
|
121
|
+
- Gemfile.lock
|
122
|
+
- LICENSE
|
123
|
+
- README.md
|
124
|
+
- Rakefile
|
125
|
+
- apphealth.gemspec
|
126
|
+
- bin/apphealth
|
127
|
+
- fixtures/domain.com.yml
|
128
|
+
- fixtures/domain.net.yml
|
129
|
+
- lib/apphealth.rb
|
130
|
+
- lib/apphealth/checker.rb
|
131
|
+
- lib/apphealth/config.rb
|
132
|
+
- lib/apphealth/server.rb
|
133
|
+
- lib/apphealth/version.rb
|
134
|
+
- spec/checker_spec.rb
|
135
|
+
- spec/config_spec.rb
|
136
|
+
- spec/server_spec.rb
|
137
|
+
- spec/spec_helper.rb
|
138
|
+
homepage: https://github.com/djfpaagman/apphealth
|
139
|
+
licenses:
|
140
|
+
- MIT
|
141
|
+
metadata: {}
|
142
|
+
post_install_message:
|
143
|
+
rdoc_options: []
|
144
|
+
require_paths:
|
145
|
+
- lib
|
146
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
147
|
+
requirements:
|
148
|
+
- - '>='
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '0'
|
151
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
|
+
requirements:
|
153
|
+
- - '>='
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
version: '0'
|
156
|
+
requirements: []
|
157
|
+
rubyforge_project:
|
158
|
+
rubygems_version: 2.1.9
|
159
|
+
signing_key:
|
160
|
+
specification_version: 4
|
161
|
+
summary: AppHealth checks the response for a specific URL on each app server
|
162
|
+
test_files:
|
163
|
+
- spec/checker_spec.rb
|
164
|
+
- spec/config_spec.rb
|
165
|
+
- spec/server_spec.rb
|
166
|
+
- spec/spec_helper.rb
|