easymon 1.0.9 → 1.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of easymon might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/lib/easymon/checklist.rb +8 -4
- data/lib/easymon/result.rb +3 -3
- data/lib/easymon/version.rb +1 -1
- data/lib/easymon.rb +5 -4
- data/test/controllers/easymon/checks_controller_test.rb +29 -8
- data/test/dummy/config/environments/development.rb +1 -1
- data/test/dummy/log/development.log +1841 -0
- data/test/dummy/log/test.log +4207 -0
- data/test/dummy/tmp/cache/4D4/7A0/health_check +1 -1
- metadata +20 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f61e81b90d2bee2ab041290388bdc30971b544d
|
4
|
+
data.tar.gz: 7d1cc5cb52e9210533cd4f4dce9786c710e76405
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0104d61a2ae1fdbecc7b2178caf0eb610eb32b3a4c2d0bc5d413bb6abe75840a1e73b8b285e42a8a48291061e92783f6053d5a29f5e3280aca7ed3e9102ee7be
|
7
|
+
data.tar.gz: e4e71ccaac26b483bdbca036c942de0cf55103341ecbe4947bf57ca5ba3c13656366fa725aeb75fae30513aab2673650e2fc968c710cfb11d46a2b4670ec8019
|
data/README.md
CHANGED
@@ -223,6 +223,10 @@ Here's the most direct way to get your work merged into the project:
|
|
223
223
|
If you're going to make a major change ask first to maje sure it's in line with
|
224
224
|
the project goals.
|
225
225
|
|
226
|
+
## To Do
|
227
|
+
|
228
|
+
See the issues page. :smile:
|
229
|
+
|
226
230
|
## Authors
|
227
231
|
|
228
232
|
* [Nathan Anderson](mailto:andnat@gmail.com)
|
data/lib/easymon/checklist.rb
CHANGED
@@ -36,12 +36,16 @@ module Easymon
|
|
36
36
|
"\n - Total Time - " + Easymon.timing_to_ms(self.timing) + "ms"
|
37
37
|
end
|
38
38
|
|
39
|
-
def
|
40
|
-
combined =
|
39
|
+
def to_hash
|
40
|
+
combined = {}
|
41
41
|
results.each do |name, result|
|
42
|
-
combined
|
42
|
+
combined[name] = result.to_hash
|
43
43
|
end
|
44
|
-
combined
|
44
|
+
combined
|
45
|
+
end
|
46
|
+
|
47
|
+
def as_json(*args)
|
48
|
+
to_hash
|
45
49
|
end
|
46
50
|
|
47
51
|
def success?
|
data/lib/easymon/result.rb
CHANGED
@@ -22,12 +22,12 @@ module Easymon
|
|
22
22
|
"#{message} - #{Easymon.timing_to_ms(timing)}ms"
|
23
23
|
end
|
24
24
|
|
25
|
-
def
|
26
|
-
to_hash
|
25
|
+
def as_json(options = {})
|
26
|
+
to_hash
|
27
27
|
end
|
28
28
|
|
29
29
|
def to_hash
|
30
|
-
{:success => success, :message => message, :timing => timing_to_ms(timing)}
|
30
|
+
{:success => success, :message => message, :timing => Easymon.timing_to_ms(timing)}
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
data/lib/easymon/version.rb
CHANGED
data/lib/easymon.rb
CHANGED
@@ -44,19 +44,20 @@ module Easymon
|
|
44
44
|
require 'easymon/checks_controller'
|
45
45
|
|
46
46
|
mapper.instance_eval do
|
47
|
-
connect "#{path}", :controller => "easymon/checks", :action => "index"
|
48
|
-
connect "#{path}/:check", :controller => "easymon/checks", :action => "show"
|
47
|
+
connect "#{path}.:format", :controller => "easymon/checks", :action => "index"
|
48
|
+
connect "#{path}/:check.:format", :controller => "easymon/checks", :action => "show"
|
49
49
|
end
|
50
50
|
elsif Easymon.rails30?
|
51
51
|
# Greater than 3.0, but less than 3.1
|
52
52
|
mapper.instance_eval do
|
53
|
-
get "#{path}" => 'easymon/checks#index'
|
53
|
+
get "#{path}(.:format)" => 'easymon/checks#index'
|
54
54
|
get "#{path}/:check" => 'easymon/checks#show'
|
55
55
|
end
|
56
56
|
elsif Easymon.mountable_engine?
|
57
57
|
# Rails 3.1+
|
58
58
|
mapper.instance_eval do
|
59
|
-
get "/", :to => "checks#index"
|
59
|
+
get "/(.:format)", :to => "checks#index"
|
60
|
+
root :to => "checks#index"
|
60
61
|
get "/:check", :to => "checks#show"
|
61
62
|
end
|
62
63
|
end
|
@@ -4,28 +4,28 @@ module Easymon
|
|
4
4
|
class ChecksControllerTest < ActionController::TestCase
|
5
5
|
|
6
6
|
test "index when no checks are defined" do
|
7
|
-
get :index, use_route
|
7
|
+
get :index, :use_route => :easymon
|
8
8
|
assert_response :service_unavailable
|
9
9
|
assert_equal "No Checks Defined", response.body
|
10
10
|
end
|
11
11
|
|
12
12
|
test "index when all checks pass" do
|
13
13
|
Easymon::Repository.add("database", Easymon::ActiveRecordCheck.new(ActiveRecord::Base))
|
14
|
-
get :index, use_route
|
14
|
+
get :index, :use_route => :easymon
|
15
15
|
assert_response :success, "Expected success, got 503: #{response.body}"
|
16
16
|
assert response.body.include?("OK"), "Should include 'OK' in response body"
|
17
17
|
end
|
18
18
|
|
19
19
|
test "index when a critical check fails" do
|
20
|
-
Easymon::Repository.add("database", Easymon::ActiveRecordCheck.new(ActiveRecord::Base),
|
20
|
+
Easymon::Repository.add("database", Easymon::ActiveRecordCheck.new(ActiveRecord::Base), :critical)
|
21
21
|
ActiveRecord::Base.connection.stubs(:select_value).raises("boom")
|
22
|
-
get :index, use_route
|
22
|
+
get :index, :use_route => :easymon
|
23
23
|
assert_response :service_unavailable
|
24
24
|
assert response.body.include?("database: Down"), "Should include failure text, got #{response.body}"
|
25
25
|
end
|
26
26
|
|
27
27
|
test "index when a non-critical check fails" do
|
28
|
-
Easymon::Repository.add("database", Easymon::ActiveRecordCheck.new(ActiveRecord::Base),
|
28
|
+
Easymon::Repository.add("database", Easymon::ActiveRecordCheck.new(ActiveRecord::Base), :critical)
|
29
29
|
Easymon::Repository.add("redis", Easymon::RedisCheck.new(YAML.load_file(Rails.root.join("config/redis.yml"))[Rails.env].symbolize_keys))
|
30
30
|
Redis.any_instance.stubs(:ping).raises("boom")
|
31
31
|
get :index, use_route: :easymon
|
@@ -34,18 +34,39 @@ module Easymon
|
|
34
34
|
assert response.body.include?("OK"), "Should include 'OK' in response body"
|
35
35
|
end
|
36
36
|
|
37
|
+
test "index returns valid json" do
|
38
|
+
Easymon::Repository.add("database", Easymon::ActiveRecordCheck.new(ActiveRecord::Base))
|
39
|
+
get :index, :use_route => :easymon, :format => :json
|
40
|
+
|
41
|
+
json = JSON.parse(response.body)
|
42
|
+
|
43
|
+
assert json.has_key?("database")
|
44
|
+
assert_equal "Up", json["database"]["message"]
|
45
|
+
assert_equal 1, json.keys.count
|
46
|
+
end
|
47
|
+
|
37
48
|
test "show when the check passes" do
|
38
49
|
Easymon::Repository.add("database", Easymon::ActiveRecordCheck.new(ActiveRecord::Base))
|
39
|
-
get :show, use_route
|
50
|
+
get :show, :use_route => :easymon, check: "database"
|
40
51
|
assert_response :success
|
41
52
|
assert response.body.include?("Up"), "Response should include message text, got #{response.body}"
|
42
53
|
end
|
43
54
|
|
55
|
+
test "show json when the check passes" do
|
56
|
+
Easymon::Repository.add("database", Easymon::ActiveRecordCheck.new(ActiveRecord::Base))
|
57
|
+
get :show, :use_route => :easymon, :check => "database", :format => :json
|
58
|
+
|
59
|
+
json = JSON.parse(response.body)
|
60
|
+
|
61
|
+
assert json.has_key?("message")
|
62
|
+
assert_equal "Up", json["message"]
|
63
|
+
end
|
64
|
+
|
44
65
|
test "show when the check fails" do
|
45
66
|
Easymon::Repository.add("database", Easymon::ActiveRecordCheck.new(ActiveRecord::Base))
|
46
67
|
ActiveRecord::Base.connection.stubs(:select_value).raises("boom")
|
47
68
|
|
48
|
-
get :show, use_route
|
69
|
+
get :show, :use_route => :easymon, :check => "database"
|
49
70
|
|
50
71
|
assert_response :service_unavailable
|
51
72
|
assert response.body.include?("Down"), "Response should include failure text, got #{response.body}"
|
@@ -54,7 +75,7 @@ module Easymon
|
|
54
75
|
test "show if the check is not found" do
|
55
76
|
Easymon::Repository.names.each {|name| Easymon::Repository.remove(name)}
|
56
77
|
|
57
|
-
get :show, use_route
|
78
|
+
get :show, :use_route => :easymon, :check => "database"
|
58
79
|
assert_response :not_found
|
59
80
|
end
|
60
81
|
end
|
@@ -27,7 +27,7 @@ Dummy::Application.configure do
|
|
27
27
|
|
28
28
|
# Log the query plan for queries taking more than this (works
|
29
29
|
# with SQLite, MySQL, and PostgreSQL)
|
30
|
-
config.active_record.auto_explain_threshold_in_seconds = 0.5
|
30
|
+
#config.active_record.auto_explain_threshold_in_seconds = 0.5
|
31
31
|
|
32
32
|
# Do not compress assets
|
33
33
|
config.assets.compress = false
|