Rack::Monitor

Rack::Monitor is Rack middleware collecting run-time information for monitoring tools like Munin.

Installation

sudo gem install rack-monitor rack-contrib

Basic Usage

Rack::Monitor is implemented as a piece of Rack middleware and can be used with any Rack-based application. If your application includes a rackup (.ru) file or uses Rack::Builder to construct the application pipeline, simply require and use as follows:

require 'rack/contrib'
require 'rack/monitor'

if ENV['RACK_ENV'] == 'production'
  use Rack::Access, '/rack_status' => [ '127.0.0.1' ]
  use Rack::Monitor, :url => '/rack_status', :watch => ['/', '/ping']
end

run app

Using with Rails

Add this to your config/environments/production.rb:

config.gem "rack-monitor", :lib => "rack/monitor"

require 'rack/monitor' #Rails bug?
config.middleware.use ::Rack::Monitor, :url => '/rack_status', :watch => ['/', '/ping']

You should now see Rack::Monitor listed in the middleware pipeline:

RAILS_ENV=production rake middleware

Rack::Monitor doesn’t work properly when started with mongrel_rails. Use thin instead.

Monitoring with Munin

Copy plugin files from github.com/pka/rack-monitor/tree/master/munin/ to /etc/munin/plugins/

Setup a configuration in /etc/munin/plugin-conf.d/ like github.com/pka/rack-monitor/tree/master/munin/plugin-conf.d/rack

/etc/init.d/munin-node restart
GitHub

github.com/pka/rack-monitor

Thanks to:

  • rack-bug

  • Rails footnotes

Copyright © 2010 Pirmin Kalberer. See LICENSE for details.