uri-health 0.0.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 +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +44 -0
- data/Rakefile +6 -0
- data/lib/uri/health.rb +6 -0
- data/lib/uri/health/status.rb +32 -0
- data/lib/uri/health/version.rb +9 -0
- data/spec/spec_helper.rb +4 -0
- data/spec/support/uris.yaml +4 -0
- data/spec/uri_health_spec.rb +16 -0
- data/uri-health.gemspec +26 -0
- metadata +116 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8cc59d728b88a63fa3122b2e8b6e517c064cdbea
|
4
|
+
data.tar.gz: 8c0de25d0eaa2b492efc1f801138d19169f99f1d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1fb3a80b3b2a50f977ad952afc2b9ea824ac79101609a1ffdd3792c80354bb0e5503458830ba3bfc2fa6c50c007e5ebf6f77c31daab205561e1a989bd171392d
|
7
|
+
data.tar.gz: 145d217e686602a8cd4b59d488c62ad9f35040ff1af2a8810512d3b9b053458b636743818a4768d335b40160667b9b75fa4dda170005415cc5f998a5ab1db296
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Ben Snape
|
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,44 @@
|
|
1
|
+
# Uri::Health
|
2
|
+
|
3
|
+
A really easy way to monitor the health of a list of endpoints over time.
|
4
|
+
|
5
|
+
## Installation and Usage
|
6
|
+
|
7
|
+
Add to your Gemfile:
|
8
|
+
|
9
|
+
gem 'uri-health'
|
10
|
+
|
11
|
+
Create a YAML file of the URIs you wish to monitor:
|
12
|
+
|
13
|
+
- http://www.google.co.uk
|
14
|
+
- http://www.yahoo.co.uk
|
15
|
+
- http://www.itv.com
|
16
|
+
- http://www.itv.com/news/uk/
|
17
|
+
|
18
|
+
Include the path to your YAML file when executing the code:
|
19
|
+
|
20
|
+
Uri::Health::Status.new('spec/support/uris.yaml').go
|
21
|
+
|
22
|
+
The status codes are returned in a hash and written to `uri-health/last_run.json`:
|
23
|
+
|
24
|
+
{
|
25
|
+
"http://www.google.co.uk": 200,
|
26
|
+
"http://www.yahoo.co.uk": 200,
|
27
|
+
"http://www.itv.com": 200,
|
28
|
+
"http://www.itv.com/news/uk/": 200
|
29
|
+
}
|
30
|
+
|
31
|
+
## TODO
|
32
|
+
|
33
|
+
1. Introduce polling over time
|
34
|
+
2. Test connection error cases
|
35
|
+
3. Parse URIs
|
36
|
+
4. A pretty report
|
37
|
+
|
38
|
+
## Contributing
|
39
|
+
|
40
|
+
1. Fork it ( http://github.com/<my-github-username>/uri-health/fork )
|
41
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
42
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
43
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
44
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/lib/uri/health.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
module Uri
|
2
|
+
|
3
|
+
module Health
|
4
|
+
|
5
|
+
class Status
|
6
|
+
|
7
|
+
def initialize(path_to_yaml)
|
8
|
+
@uris = YAML.load_file(path_to_yaml)
|
9
|
+
end
|
10
|
+
|
11
|
+
def go
|
12
|
+
responses = {}
|
13
|
+
@uris.each do |uri|
|
14
|
+
responses.merge!({uri => HTTParty.get(uri).code})
|
15
|
+
end
|
16
|
+
|
17
|
+
output_json(responses)
|
18
|
+
responses
|
19
|
+
end
|
20
|
+
|
21
|
+
def output_json(output)
|
22
|
+
Dir.mkdir 'uri-health' unless File.directory? 'uri-health'
|
23
|
+
File.open('uri-health/last_run.json', 'w') do |f|
|
24
|
+
f.write(output.to_json)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require_relative 'spec_helper'
|
2
|
+
|
3
|
+
describe Uri::Health do
|
4
|
+
|
5
|
+
it 'should read URIs from a YAML file and return a hash with status codes' do
|
6
|
+
responses = Uri::Health::Status.new('spec/support/uris.yaml').go
|
7
|
+
responses.each { |uri, status_code| status_code.should be_a_kind_of(Fixnum) }
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should generate a JSON run report' do
|
11
|
+
response = Uri::Health::Status.new('spec/support/uris.yaml').go
|
12
|
+
generated_json_file = File.read 'uri-health/last_run.json'
|
13
|
+
response.to_json.should == generated_json_file
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
data/uri-health.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'uri/health/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'uri-health'
|
8
|
+
spec.version = Uri::Health::VERSION
|
9
|
+
spec.authors = ['Ben Snape']
|
10
|
+
spec.email = %w(bsnape@gmail.com)
|
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
|
+
spec.homepage = 'http://www.bensnape.com'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = %w(lib)
|
20
|
+
|
21
|
+
spec.add_dependency 'httparty', '~> 0'
|
22
|
+
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.5'
|
24
|
+
spec.add_development_dependency 'rake', '~> 10'
|
25
|
+
spec.add_development_dependency 'rspec', '~> 2'
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: uri-health
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ben Snape
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-01-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.5'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.5'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2'
|
69
|
+
description: "[\"Easily\", \"monitor\", \"the\", \"health\", \"of\", \"arbitrary\",
|
70
|
+
\"URI's\", \"defined\", \"in\", \"YAML\", \"config\"]"
|
71
|
+
email:
|
72
|
+
- bsnape@gmail.com
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- lib/uri/health.rb
|
83
|
+
- lib/uri/health/status.rb
|
84
|
+
- lib/uri/health/version.rb
|
85
|
+
- spec/spec_helper.rb
|
86
|
+
- spec/support/uris.yaml
|
87
|
+
- spec/uri_health_spec.rb
|
88
|
+
- uri-health.gemspec
|
89
|
+
homepage: http://www.bensnape.com
|
90
|
+
licenses:
|
91
|
+
- MIT
|
92
|
+
metadata: {}
|
93
|
+
post_install_message:
|
94
|
+
rdoc_options: []
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
requirements: []
|
108
|
+
rubyforge_project:
|
109
|
+
rubygems_version: 2.2.0
|
110
|
+
signing_key:
|
111
|
+
specification_version: 4
|
112
|
+
summary: "[\"Monitor\", \"the\", \"health\", \"of\", \"URI's\"]"
|
113
|
+
test_files:
|
114
|
+
- spec/spec_helper.rb
|
115
|
+
- spec/support/uris.yaml
|
116
|
+
- spec/uri_health_spec.rb
|