Sha256: 54180b94f4ac7d5de9809af6aa98d7bab8beb98f4fd10b42b822c9a118315b2a

Contents?: true

Size: 912 Bytes

Versions: 1

Compression:

Stored size: 912 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,10).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

1 entries across 1 versions & 1 rubygems

Version Path
city-watch-0.5.2 lib/city_watch/commander/server.rb