Class: Mongrel::StatusHandler
- Inherits:
-
HttpHandler
- Object
- HttpHandler
- Mongrel::StatusHandler
- Defined in:
- lib/mongrel/handlers.rb
Overview
The :stats_filter is basically any configured stats filter that you’ve added to this same URI. This lets the status handler print out statistics on how Mongrel is doing.
Instance Attribute Summary
Attributes inherited from HttpHandler
Instance Method Summary collapse
- #describe_listener ⇒ Object
-
#initialize(ops = {}) ⇒ StatusHandler
constructor
A new instance of StatusHandler.
- #process(request, response) ⇒ Object
- #table(title, rows) ⇒ Object
Methods inherited from HttpHandler
#request_begins, #request_progress
Constructor Details
#initialize(ops = {}) ⇒ StatusHandler
Returns a new instance of StatusHandler.
371 372 373 |
# File 'lib/mongrel/handlers.rb', line 371 def initialize(ops={}) @stats = ops[:stats_filter] end |
Instance Method Details
#describe_listener ⇒ Object
385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 |
# File 'lib/mongrel/handlers.rb', line 385 def describe_listener results = "" results << "<h1>Listener #{listener.host}:#{listener.port}</h1>" results << table("settings", [ ["host",listener.host], ["port",listener.port], ["throttle",listener.throttle], ["timeout",listener.timeout], ["workers max",listener.num_processors], ]) if @stats results << "<h2>Statistics</h2><p>N means the number of samples, pay attention to MEAN, SD, MIN and MAX." results << "<pre>#{@stats.dump}</pre>" end results << "<h2>Registered Handlers</h2>" handler_map = listener.classifier.handler_map results << table("handlers", handler_map.map {|uri,handlers| [uri, "<pre>" + handlers.map {|h| h.class.to_s }.join("\n") + "</pre>" ] }) results end |
#process(request, response) ⇒ Object
414 415 416 417 418 419 420 421 422 |
# File 'lib/mongrel/handlers.rb', line 414 def process(request, response) response.start do |head,out| out.write <<-END <html><body><title>Mongrel Server Status</title> #{describe_listener} </body></html> END end end |
#table(title, rows) ⇒ Object
375 376 377 378 379 380 381 382 383 |
# File 'lib/mongrel/handlers.rb', line 375 def table(title, rows) results = "<table border=\"1\"><tr><th colspan=\"#{rows[0].length}\">#{title}</th></tr>" rows.each do |cols| results << "<tr>" cols.each {|col| results << "<td>#{col}</td>" } results << "</tr>" end results + "</table>" end |