Most rails applications have many additional moving parts of which the health cannot be assessed with simply pinging the (hopefully page cached) homepage
- 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
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.
sudo gem install health_monitor --source=http://gemcutter.org config.gem :health_monitor, :source => http://gemcutter.org
Create a the health monitor controller
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 are automatically generated:
Monitor specific tasks or skip tasks with the parameters skip and only