litmus_paper 0.8.3 → 0.8.4
Sign up to get free protection for your applications and to get access to all the features.
data/lib/litmus_paper/app.rb
CHANGED
@@ -3,14 +3,15 @@ module LitmusPaper
|
|
3
3
|
disable :show_exceptions
|
4
4
|
|
5
5
|
get "/" do
|
6
|
-
output = "Litmus Paper #{LitmusPaper::VERSION}\n
|
7
|
-
|
8
|
-
output += "
|
6
|
+
output = "Litmus Paper #{LitmusPaper::VERSION}\n"
|
7
|
+
max_service_length = (LitmusPaper.services.keys << "Service").max { |a, b| a.length <=> b.length }.length
|
8
|
+
output += sprintf " %-#{max_service_length}s %6s [%s] [%s]\n", "", "", "Measured", "Forced"
|
9
|
+
output += sprintf " %-#{max_service_length}s %6s [%s] [%s]\n", "Service", "Health", "Health".center(8), "Reason"
|
9
10
|
LitmusPaper.services.each do |service_name, service|
|
10
11
|
health = service.current_health
|
11
|
-
output += "*
|
12
|
+
output += sprintf "* %-#{max_service_length}s %6s", service_name, health.value
|
12
13
|
if health.forced?
|
13
|
-
output += "
|
14
|
+
output += sprintf " %10s %s", health.measured_health, service.current_health.forced_reason
|
14
15
|
end
|
15
16
|
output += "\n"
|
16
17
|
end
|
@@ -51,6 +52,7 @@ module LitmusPaper
|
|
51
52
|
body = "Health: #{health.value}\n"
|
52
53
|
if health.forced?
|
53
54
|
body << "Measured Health: #{health.measured_health}\n"
|
55
|
+
body << "Forced Reason: #{health.forced_reason}\n"
|
54
56
|
end
|
55
57
|
body << health.summary
|
56
58
|
|
data/lib/litmus_paper/health.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
module LitmusPaper
|
2
2
|
class Health
|
3
3
|
|
4
|
-
attr_reader :summary
|
4
|
+
attr_reader :summary, :forced_reason
|
5
5
|
|
6
|
-
def initialize(forced = :none,
|
6
|
+
def initialize(forced = :none, forced_reason = "")
|
7
7
|
@value = 0
|
8
8
|
@dependencies_available = true
|
9
|
-
@summary =
|
9
|
+
@summary = ""
|
10
10
|
@forced = forced
|
11
|
+
@forced_reason = forced_reason
|
11
12
|
end
|
12
13
|
|
13
14
|
def ok?
|
data/lib/litmus_paper/version.rb
CHANGED
@@ -35,7 +35,7 @@ describe LitmusPaper::App do
|
|
35
35
|
get "/"
|
36
36
|
|
37
37
|
last_response.status.should == 200
|
38
|
-
last_response.body.should
|
38
|
+
last_response.body.should match(/\* test +0\n/)
|
39
39
|
end
|
40
40
|
|
41
41
|
it "includes the status if forced" do
|
@@ -48,8 +48,8 @@ describe LitmusPaper::App do
|
|
48
48
|
get "/"
|
49
49
|
|
50
50
|
last_response.status.should == 200
|
51
|
-
last_response.body.should
|
52
|
-
last_response.body.should
|
51
|
+
last_response.body.should match(/\* another +0 +0 +Down for testing\n/)
|
52
|
+
last_response.body.should match(/\* test +100 +0 +Up for testing\n/)
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
@@ -26,7 +26,7 @@ describe LitmusPaper::Service do
|
|
26
26
|
LitmusPaper::StatusFile.service_down_file("test").create("Down for testing")
|
27
27
|
|
28
28
|
service.current_health.value.should == 0
|
29
|
-
service.current_health.
|
29
|
+
service.current_health.forced_reason.should match(/Down for testing/)
|
30
30
|
end
|
31
31
|
|
32
32
|
it "is 0 when a global down file exists" do
|
@@ -37,7 +37,7 @@ describe LitmusPaper::Service do
|
|
37
37
|
LitmusPaper::StatusFile.global_down_file.create("Down for testing")
|
38
38
|
|
39
39
|
service.current_health.value.should == 0
|
40
|
-
service.current_health.
|
40
|
+
service.current_health.forced_reason.should match(/Down for testing/)
|
41
41
|
end
|
42
42
|
|
43
43
|
it "is 100 when an up file exists" do
|
@@ -48,7 +48,7 @@ describe LitmusPaper::Service do
|
|
48
48
|
LitmusPaper::StatusFile.service_up_file("test").create("Up for testing")
|
49
49
|
|
50
50
|
service.current_health.value.should == 100
|
51
|
-
service.current_health.
|
51
|
+
service.current_health.forced_reason.should match(/Up for testing/)
|
52
52
|
end
|
53
53
|
|
54
54
|
it "is 100 when a global up file exists" do
|
@@ -59,7 +59,7 @@ describe LitmusPaper::Service do
|
|
59
59
|
LitmusPaper::StatusFile.global_up_file.create("Up for testing")
|
60
60
|
|
61
61
|
service.current_health.value.should == 100
|
62
|
-
service.current_health.
|
62
|
+
service.current_health.forced_reason.should match(/Up for testing/)
|
63
63
|
end
|
64
64
|
end
|
65
65
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: litmus_paper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-05-
|
12
|
+
date: 2014-05-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sinatra
|
@@ -246,15 +246,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
246
246
|
- - ! '>='
|
247
247
|
- !ruby/object:Gem::Version
|
248
248
|
version: '0'
|
249
|
+
segments:
|
250
|
+
- 0
|
251
|
+
hash: -2773355175135324952
|
249
252
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
250
253
|
none: false
|
251
254
|
requirements:
|
252
255
|
- - ! '>='
|
253
256
|
- !ruby/object:Gem::Version
|
254
257
|
version: '0'
|
258
|
+
segments:
|
259
|
+
- 0
|
260
|
+
hash: -2773355175135324952
|
255
261
|
requirements: []
|
256
262
|
rubyforge_project:
|
257
|
-
rubygems_version: 1.8.
|
263
|
+
rubygems_version: 1.8.24
|
258
264
|
signing_key:
|
259
265
|
specification_version: 3
|
260
266
|
summary: Backend health tester for HA Services, partner project of big_brother
|