3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/litmus_paper/agent_check_handler.rb', line 3
def self.handle(service)
@cache ||= LitmusPaper::Cache.new(
LitmusPaper.cache_location,
"litmus_agent_cache",
LitmusPaper.cache_ttl
)
output = []
if !service
return "failed#BAD_INPUT"
end
health = @cache.get(service)
if !health
@cache.set(
service,
health = LitmusPaper.check_service(service)
)
end
if health.nil?
output << "failed#NOT_FOUND"
else
case health.direction
when :up, :health
output << "ready" output << "up" when :down
output << "drain" when :none
if health.ok?
output << "ready" output << "up" else
output << "down" end
end
output << "#{health.value.to_s}%"
end
output.join("\t")
end
|