eir 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -9
- data/Rakefile +1 -1
- data/bin/eir +9 -2
- data/dashboard.png +0 -0
- data/eir.gemspec +5 -3
- data/lib/eir/app/app.rb +3 -3
- data/lib/eir/request.rb +7 -9
- data/lib/eir/server.rb +3 -5
- data/lib/eir/version.rb +1 -1
- data/spec/eir_spec.rb +11 -10
- metadata +31 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6bc6edca9fcc731c1855a972cae9fd098a9e0bb
|
4
|
+
data.tar.gz: dd6a2e65a5d6e3b778803a547eb7edd4d91087c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4deae98b58ddd6fec2a76e6c590a94c827784e0368d1aaf520309f422121a504dbea07dc2e8544cf9c7156f49325b7ef4e270a36ed2ee7ccf5d6207a69369c9e
|
7
|
+
data.tar.gz: a664d77f3e9c4aed439e8c97bfa14b06574de784c8650ae2c5f74dbdb4f38d73405a92764875382bae15a9b7d6ef67fd4fbb51de38a14c5274427e17ae3fdd1f
|
data/README.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
A really easy way to monitor the health of a list of endpoints over time.
|
4
4
|
|
5
|
+
![Example Dashboard](dashboard.png)
|
6
|
+
|
5
7
|
## Installation and Usage
|
6
8
|
|
7
9
|
Add to your Gemfile:
|
@@ -38,12 +40,4 @@ A successfully running app should have a directory structure like this:
|
|
38
40
|
1. Test connection error cases
|
39
41
|
2. Parse/validate URIs
|
40
42
|
3. Validate YAML
|
41
|
-
4.
|
42
|
-
|
43
|
-
## Contributing
|
44
|
-
|
45
|
-
1. Fork it ( http://github.com/<my-github-username>/eir/fork )
|
46
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
47
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
48
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
49
|
-
5. Create new Pull Request
|
43
|
+
4. Some decent CSS/JS (please help!)
|
data/Rakefile
CHANGED
data/bin/eir
CHANGED
@@ -1,7 +1,14 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib') unless $LOAD_PATH.include?(File.dirname(__FILE__) + '/../lib')
|
3
3
|
|
4
4
|
require 'bundler/setup'
|
5
5
|
require 'eir'
|
6
|
+
require 'colorize'
|
6
7
|
|
7
|
-
|
8
|
+
if ARGV.first == '--to-console'
|
9
|
+
Eir::Request.new.go.each do |service, status_code|
|
10
|
+
puts (status_code == 200) ? service.colorize(:green) : service.colorize(:red)
|
11
|
+
end
|
12
|
+
else
|
13
|
+
Eir::Server.new.start
|
14
|
+
end
|
data/dashboard.png
ADDED
Binary file
|
data/eir.gemspec
CHANGED
@@ -8,12 +8,12 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = Eir::VERSION
|
9
9
|
spec.authors = ['Ben Snape']
|
10
10
|
spec.email = %w(bsnape@gmail.com)
|
11
|
-
spec.summary = %w
|
12
|
-
spec.description = %w
|
11
|
+
spec.summary = %w(Monitor the health of URI's)
|
12
|
+
spec.description = %w(Easily monitor the health of arbitrary URI's defined in YAML config)
|
13
13
|
spec.homepage = 'http://www.bensnape.com'
|
14
14
|
spec.license = 'MIT'
|
15
15
|
|
16
|
-
spec.files = `git ls-files`.split(
|
16
|
+
spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = %w(lib)
|
@@ -22,9 +22,11 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_dependency 'sinatra', '~> 1.4.5'
|
23
23
|
spec.add_dependency 'haml', '~> 4'
|
24
24
|
spec.add_dependency 'puma', '~> 2.8.2'
|
25
|
+
spec.add_dependency 'colorize', '~> 0.7.3'
|
25
26
|
|
26
27
|
spec.add_development_dependency 'bundler', '~> 1.5'
|
27
28
|
spec.add_development_dependency 'rake', '~> 10'
|
28
29
|
spec.add_development_dependency 'rspec', '~> 2'
|
29
30
|
spec.add_development_dependency 'rack-test', '~> 0.6.2'
|
31
|
+
spec.add_development_dependency 'rubocop', '~> 0.26.0'
|
30
32
|
end
|
data/lib/eir/app/app.rb
CHANGED
@@ -16,9 +16,9 @@ class App < Sinatra::Base
|
|
16
16
|
end
|
17
17
|
|
18
18
|
get '/' do
|
19
|
-
@eir
|
20
|
-
@responses
|
21
|
-
haml :dashboard, :
|
19
|
+
@eir = Eir::Request.new
|
20
|
+
@responses = @eir.go
|
21
|
+
haml :dashboard, layout: (request.xhr? ? false : :layout)
|
22
22
|
end
|
23
23
|
|
24
24
|
end
|
data/lib/eir/request.rb
CHANGED
@@ -24,26 +24,24 @@ module Eir
|
|
24
24
|
def validate_yaml(path_to_yaml)
|
25
25
|
invalid_yaml_error = 'YAML structure incorrect. Please refer to the README.'
|
26
26
|
yaml = YAML.load_file path_to_yaml
|
27
|
-
|
28
|
-
yaml.each { |hash|
|
27
|
+
fail(invalid_yaml_error) unless yaml.is_a? Array
|
28
|
+
yaml.each { |hash| fail(invalid_yaml_error) unless hash.is_a? Hash }
|
29
29
|
yaml
|
30
30
|
end
|
31
31
|
|
32
32
|
def get_http_response_code(uri)
|
33
|
-
|
34
|
-
|
35
|
-
request(uri).code
|
36
|
-
end
|
37
|
-
rescue
|
38
|
-
false
|
33
|
+
Timeout.timeout(5) do
|
34
|
+
request(uri).code
|
39
35
|
end
|
36
|
+
rescue
|
37
|
+
false
|
40
38
|
end
|
41
39
|
|
42
40
|
def go
|
43
41
|
responses = {}
|
44
42
|
@uris.each do |uri_name_hash|
|
45
43
|
uri_name_hash.each do |uri, name|
|
46
|
-
responses.merge!(
|
44
|
+
responses.merge!(name => get_http_response_code(uri))
|
47
45
|
end
|
48
46
|
end
|
49
47
|
|
data/lib/eir/server.rb
CHANGED
@@ -18,11 +18,9 @@ module Eir
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def status
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
false
|
25
|
-
end
|
21
|
+
RestClient.get("#{@server_url}/status").code
|
22
|
+
rescue Errno::ECONNREFUSED
|
23
|
+
false
|
26
24
|
end
|
27
25
|
|
28
26
|
def start
|
data/lib/eir/version.rb
CHANGED
data/spec/eir_spec.rb
CHANGED
@@ -4,31 +4,32 @@ describe Eir do
|
|
4
4
|
|
5
5
|
it 'should look for custom YAML in the current directory' do
|
6
6
|
File.open('uris.yaml', 'w+') { |f| f.write('- http://www.google.co.uk : Google') }
|
7
|
-
Eir::Request.new.uris.
|
7
|
+
expect(Eir::Request.new.uris).to eq([{ 'http://www.google.co.uk' => 'Google' }])
|
8
8
|
File.delete 'uris.yaml'
|
9
9
|
end
|
10
10
|
|
11
11
|
it 'should fall back to a list of default URIs if no local YAML file is present' do
|
12
|
-
Eir::Request.new.uris.
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
12
|
+
expect(Eir::Request.new.uris).to eq(
|
13
|
+
[
|
14
|
+
{ 'http://www.google.co.uk' => 'Google' },
|
15
|
+
{ 'http://www.yahoo.co.uk' => 'Yahoo' },
|
16
|
+
{ 'http://www.itv.com' => 'ITV' }
|
17
|
+
]
|
18
|
+
)
|
18
19
|
end
|
19
20
|
|
20
21
|
it 'should make an HTTP request for each URI' do
|
21
22
|
@request = Eir::Request.new
|
22
23
|
@request.stub(:get_http_response_code).and_return(200)
|
23
24
|
responses = @request.go
|
24
|
-
responses.each { |
|
25
|
+
responses.each { |_, status_code| expect(status_code).to eq(200) }
|
25
26
|
end
|
26
27
|
|
27
28
|
it 'should return a hash of the URL alias and status code' do
|
28
29
|
@request = Eir::Request.new
|
29
30
|
@request.stub(:get_http_response_code).and_return(200)
|
30
31
|
responses = @request.go
|
31
|
-
responses.
|
32
|
+
expect(responses).to eq('Google' => 200, 'Yahoo' => 200, 'ITV' => 200)
|
32
33
|
end
|
33
34
|
|
34
35
|
it 'should time out after 5 seconds for an unresponsive status call' do
|
@@ -36,7 +37,7 @@ describe Eir do
|
|
36
37
|
@request.uris = [{ 'http://www.google.co.uk' => 'Google' }]
|
37
38
|
@request.stub(:request) { sleep 10 }
|
38
39
|
responses = @request.go
|
39
|
-
responses.
|
40
|
+
expect(responses).to eq('Google' => false)
|
40
41
|
end
|
41
42
|
|
42
43
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eir
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Snape
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06
|
11
|
+
date: 2014-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 2.8.2
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: colorize
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.7.3
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.7.3
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: bundler
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,6 +136,20 @@ dependencies:
|
|
122
136
|
- - "~>"
|
123
137
|
- !ruby/object:Gem::Version
|
124
138
|
version: 0.6.2
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rubocop
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: 0.26.0
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 0.26.0
|
125
153
|
description: "[\"Easily\", \"monitor\", \"the\", \"health\", \"of\", \"arbitrary\",
|
126
154
|
\"URI's\", \"defined\", \"in\", \"YAML\", \"config\"]"
|
127
155
|
email:
|
@@ -137,6 +165,7 @@ files:
|
|
137
165
|
- README.md
|
138
166
|
- Rakefile
|
139
167
|
- bin/eir
|
168
|
+
- dashboard.png
|
140
169
|
- eir.gemspec
|
141
170
|
- lib/eir.rb
|
142
171
|
- lib/eir/app/app.rb
|