ez_healthcheck 0.0.0 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/ez_healthcheck.gemspec +2 -2
- data/lib/ez_healthcheck.rb +50 -2
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.1.0
|
data/ez_healthcheck.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{ez_healthcheck}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.1.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["t11a"]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-12-04}
|
13
13
|
s.description = %q{This gem is easily health-checking your server}
|
14
14
|
s.email = %q{tsuyoshi.ogawa@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/ez_healthcheck.rb
CHANGED
@@ -1,5 +1,53 @@
|
|
1
|
+
require "net/http"
|
2
|
+
require "rubygems"
|
3
|
+
require "aws-sdk"
|
4
|
+
|
1
5
|
class EzHealthcheck
|
2
|
-
|
3
|
-
|
6
|
+
attr_accessor :codes, :host, :ses
|
7
|
+
|
8
|
+
def initialize(host, id, key)
|
9
|
+
@codes = {}
|
10
|
+
@host = host
|
11
|
+
@ses = AWS::SimpleEmailService.new(
|
12
|
+
:access_key_id => id,
|
13
|
+
:secret_access_key => key
|
14
|
+
)
|
4
15
|
end
|
16
|
+
|
17
|
+
def access(paths=[])
|
18
|
+
paths.each do |path|
|
19
|
+
puts path
|
20
|
+
response = Net::HTTP.get_response(@host,path)
|
21
|
+
case response
|
22
|
+
when Net::HTTPInformation
|
23
|
+
puts "1xx"
|
24
|
+
when Net::HTTPSuccess
|
25
|
+
puts "2xx"
|
26
|
+
when Net::HTTPRedirection
|
27
|
+
puts "3xx"
|
28
|
+
when Net::HTTPClientError
|
29
|
+
puts "4xx"
|
30
|
+
when Net::HTTPServerError
|
31
|
+
puts "5xx"
|
32
|
+
else
|
33
|
+
puts "unknown"
|
34
|
+
end
|
35
|
+
@codes.store(path, response.code)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def send_email(params={})
|
40
|
+
begin
|
41
|
+
@ses.send_email(
|
42
|
+
:subject => params[:subject],
|
43
|
+
:from => params[:from],
|
44
|
+
:to => params[:to],
|
45
|
+
:body_text => params[:body_text],
|
46
|
+
:body_html => params[:body_html]
|
47
|
+
)
|
48
|
+
rescue => ex
|
49
|
+
puts ex
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
5
53
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ez_healthcheck
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 0.0.0
|
10
|
+
version: 0.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- t11a
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-12-04 00:00:00 +09:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|