monitor rails health" />

Rails Application Health Monitor

December 13, 2009

hot-thermometer
Most rails applications have many additional moving parts of which the health cannot be assessed with simply pinging the (hopefully page cached) homepage

For example,

  • Is Email is sent successfully?
  • Is the SMS gateway alive and you bought sufficient credits?
  • All database connections are alive? Backgroundrb down again?
  • The cloud computing setup jacked the imagemagick? Again?
  • You are running out of disk space and there are no more file descriptors for your
  • The git SHA and version is correct
  • Screen shot 2009-12-06 at 12.29.53 AM

Health Monitor adds a single controller action to generate an html, js, or xml report with details of all your custom defined health checks. An error response code (500 server error) indicates failure when any monitored feature fails or exceeds the custom timeout definition. Health monitor is easier to setup than custom server side cron tasks and adds the advantage of exercising more code since everything from your load balancer to nginx to mongrels must be happily shoving rubies around to get that 200 oh boy success message. So ping away, grab a beer and know that hey, you might be too drunk but at least you will know your application is sick before your clients do.

Install

sudo gem install health_monitor --source=http://gemcutter.org

config.gem :health_monitor, :source => http://gemcutter.org

Create a the health monitor controller

script/generate health_monitor

Add your customizations

  class HealthMonitorController < ApplicationController
    acts_as_health_monitor

    #More examples available at http://github.com/blythedunham/health_monitor
    #Built in checks
    monitor_health :schema_check, :database_check, :ey_agent_check

    #monitor specified process
    monitor_process :monit 

    # Custom monitor task
    monitor_health :email, :description => 'send an email' do |controller|
      ActionMailer::Base.deliver_my_mail('blah')
    end
  end

Routes

Routes are automatically generated:

http://localhost:3000/health_monitor

http://localhost:3000/health_monitor.js

Monitor specific tasks or skip tasks with the parameters skip and only

http://localhost:3000/health_monitor?only=schema_check,database_check

http://localhost:3000/health_monitor?skip=email,database_check

Leave a Reply