city-watch 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
@@ -13,13 +13,13 @@ class ResendRequest
|
|
13
13
|
post_data[:watchmen].each do |watchman,dat|
|
14
14
|
CityWatch.redis.zadd "#{CityWatch.config[:prefix]}::#{post_data[:hostname]}::#{watchman}", Time.now.to_i, Yajl::Encoder.encode(dat.merge({:received_at => post_data[:received_at]}))
|
15
15
|
if dat[:summary]
|
16
|
-
sum = dat[:summary].is_a?(Array) ? dat[:summary].inject({}) {|acc,k| acc[k.to_sym] = dat[k.to_sym]; acc}
|
16
|
+
sum = dat[:summary].is_a?(Array) ? dat[:summary].inject({}) {|acc,k| acc[k.to_sym] = dat[k.to_sym]; acc} : dat[:summary]
|
17
17
|
CityWatch.redis.zadd "#{CityWatch.config[:prefix]}::#{post_data[:hostname]}::#{watchman}::summary", Time.now.to_i, Yajl::Encoder.encode(sum)
|
18
18
|
summary[watchman] = sum
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
CityWatch.redis.zadd "#{CityWatch.config[:prefix]}::#{post_data[:hostname]}::summary", Time.now.to_i, Yajl::Encoder.encode(summary)
|
22
|
+
CityWatch.redis.zadd "#{CityWatch.config[:prefix]}::#{post_data[:hostname]}::summary", Time.now.to_i, Yajl::Encoder.encode(summary.merge({:received_at => post_data[:received_at]}))
|
23
23
|
|
24
24
|
[200,{"Content-Type" => "text/plain"},["Got it!"]]
|
25
25
|
end
|
@@ -1,14 +1,14 @@
|
|
1
|
-
class
|
1
|
+
class Home
|
2
2
|
|
3
3
|
def call(env)
|
4
4
|
|
5
|
-
output = "Known servers
|
6
|
-
|
5
|
+
output = "<html><body><h1>Known servers:</h1><ul>"
|
7
6
|
CityWatch.redis.smembers("#{CityWatch.config[:prefix]}::known_hosts").each do |server|
|
8
|
-
output << "
|
7
|
+
output << "<li><a href="">#{server}</a>: <pre>" << CityWatch.redis.zrevrange("#{CityWatch.config[:prefix]}::#{server}::summary",0,0).first << "</pre></li>"
|
9
8
|
end
|
9
|
+
output << "</ul></body></html>"
|
10
10
|
|
11
|
-
[200,{"Content-Type" => "text/
|
11
|
+
[200,{"Content-Type" => "text/html"},[output]]
|
12
12
|
end
|
13
13
|
|
14
14
|
Routes.add_route new, { :request_method => 'GET', :path_info => %r{^/} }, {}, :home
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Server
|
2
|
+
|
3
|
+
def call(env)
|
4
|
+
|
5
|
+
parms = Rack::Request.new(env).params.merge(env["rack.routing_args"]).inject({}){|acc,(k,v)| acc[k.to_sym] = v; acc}
|
6
|
+
server = parms[:server]
|
7
|
+
|
8
|
+
output = "<html><body><h1>" << server << "</h1><ul>"
|
9
|
+
CityWatch.redis.zrevrange("#{CityWatch.config[:prefix]}::#{server}::raw_stats",0,100).each do |update|
|
10
|
+
output << "<li><pre>" << update << "</pre></li>"
|
11
|
+
end
|
12
|
+
output << "</ul></body></html>"
|
13
|
+
|
14
|
+
[200,{"Content-Type" => "text/html"},[output]]
|
15
|
+
end
|
16
|
+
|
17
|
+
Routes.add_route new, { :request_method => 'GET', :path_info => %r{^/(?<server>[\w]+)$} }, {}, :server
|
18
|
+
|
19
|
+
end
|
data/lib/version.rb
CHANGED