Mongrel::StatusHandler

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.

Public Class Methods

new(ops={}) click to toggle source
     # File lib/mongrel/handlers.rb, line 371
371:     def initialize(ops={})
372:       @stats = ops[:stats_filter]
373:     end

Public Instance Methods

describe_listener() click to toggle source
     # File lib/mongrel/handlers.rb, line 385
385:     def describe_listener
386:       results = ""
387:       results << "<h1>Listener #{listener.host}:#{listener.port}</h1>"
388:       results << table("settings", [
389:                        ["host",listener.host],
390:                        ["port",listener.port],
391:                        ["throttle",listener.throttle],
392:                        ["timeout",listener.timeout],
393:                        ["workers max",listener.num_processors],
394:       ])
395: 
396:       if @stats
397:         results << "<h2>Statistics</h2><p>N means the number of samples, pay attention to MEAN, SD, MIN and MAX."
398:         results << "<pre>#{@stats.dump}</pre>"
399:       end
400: 
401:       results << "<h2>Registered Handlers</h2>"
402:       handler_map = listener.classifier.handler_map
403:       results << table("handlers", handler_map.map {|uri,handlers| 
404:         [uri, 
405:             "<pre>" + 
406:             handlers.map {|h| h.class.to_s }.join("\n") + 
407:             "</pre>"
408:         ]
409:       })
410: 
411:       results
412:     end
process(request, response) click to toggle source
     # File lib/mongrel/handlers.rb, line 414
414:     def process(request, response)
415:       response.start do |head,out|
416:         out.write         <html><body><title>Mongrel Server Status</title>        #{describe_listener}        </body></html>
417:       end
418:     end
table(title, rows) click to toggle source
     # File lib/mongrel/handlers.rb, line 375
375:     def table(title, rows)
376:       results = "<table border=\"1\"><tr><th colspan=\"#{rows[0].length}\">#{title}</th></tr>"
377:       rows.each do |cols|
378:         results << "<tr>"
379:         cols.each {|col| results << "<td>#{col}</td>" }
380:         results << "</tr>"
381:       end
382:       results + "</table>"
383:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.