Sha256: 950c0240e0e67148301ce62282221a6209aa90d58ff0df916beac52626558760

Contents?: true

Size: 913 Bytes

Versions: 11

Compression:

Stored size: 913 Bytes

Contents

class Server
	
	def call(env)
		
		parms = Rack::Request.new(env).params.merge(env["rack.routing_args"]).inject({}){|acc,(k,v)| acc[k.to_sym] = v; acc}
		server = parms[:server]
		
		output = CityWatch.header << '<h1>' << server << "</h1><ul>"
		CityWatch.redis.zrevrange("#{CityWatch.config[:prefix]}::#{server}::raw_stats",0,100).each do |update|
			dat = Yajl::Parser.new(:symbolize_keys => true).parse(update)
			output << "<li><h4>" << dat[:received_at] << "</h4><ul>"
			dat[:watchmen].each do |name,datr|
				output << "<li><strong>" << name.to_s << ":</strong> <pre><code>" << Yajl::Encoder.encode(datr,:pretty => true, :indent => "   ") << "</code></pre></li>"
			end
			output << "</ul></li>"
		end
		output << "</ul></body></html>"
		
		[200,{"Content-Type" => "text/html"},[output]]
	end
	
	Routes.add_route new, { :request_method => 'GET', :path_info => %r{^/(?<server>[\w\.]+)$} }, {}, :server
	
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
city-watch-0.5.1 lib/city_watch/commander/server.rb
city-watch-0.5.0 lib/city_watch/commander/server.rb
city-watch-0.4.9 lib/city_watch/commander/server.rb
city-watch-0.4.7 lib/city_watch/commander/server.rb
city-watch-0.4.6 lib/city_watch/commander/server.rb
city-watch-0.4.5 lib/city_watch/commander/server.rb
city-watch-0.4.4 lib/city_watch/commander/server.rb
city-watch-0.4.3 lib/city_watch/commander/server.rb
city-watch-0.4.2 lib/city_watch/commander/server.rb
city-watch-0.4.1 lib/city_watch/commander/server.rb
city-watch-0.4.0 lib/city_watch/commander/server.rb