city-watch 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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}.merge({:received_at => post_data[:received_at]}) : dat[:summary]
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 ResendRequest
1
+ class Home
2
2
 
3
3
  def call(env)
4
4
 
5
- output = "Known servers:\n\n"
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 << "#{server}: ".ljust(20) << CityWatch.redis.zrevrange("#{CityWatch.config[:prefix]}::#{server}::summary",0,0).first << "\n"
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/plain"},[output]]
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
@@ -1,3 +1,3 @@
1
1
  module CityWatch
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: city-watch
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.3.2
5
+ version: 0.3.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - John Bragg