Simple health check of Rails app for use with Pingdom, NewRelic, EngineYard or uptime.openacs.org etc.
The basic goal is to quickly check that rails is up and running and that it has access to correctly configured resources (database, email gateway)
The email gateway is not checked unless the smtp settings have been changed. Specify full or include email in the list of checks to varify the smtp settings (eg use 127.0.0.1 instead of localhost).
health_check provides various monitoring URIs
% curl localhost:3000/health_check success % curl localhost:3000/health_check/standard success % curl localhost:3000/health_check/all success % curl localhost:3000/health_check/site_and_database_and_email_migrations success
The health_check controller disables sessions and logging for its actions to minimise the impact of frequent uptime checks on the session store and the log file.
Add the following line to Gemfile
gem "health_check"
Then run
% bundle
Install the gem using the following command
% gem install health_check
Then add the following line to config/environment.rb within the config block
config.gem "health_check"
Run the following commands from the root of your rails application
% cd vendor/plugins % git clone git://github.com/ianheggie/health_check.git
Use a website monitoring service to check the url regularly for the word “success” rather than just a 200 return code.
See
-
Pingdom Website Monitoring - www.pingdom.com
-
NewRelic Availability Monitoring - newrelic.com/docs/features/availability-monitoring-faq
-
Uptime by OpenACS - uptime.openacs.org/uptime/
-
Engine Yard’s guide - support.cloud.engineyard.com/entries/20996821-monitor-application-uptime (although the guide is based on fitter_happier plugin it will also work with this gem)
-
Any other montoring service that can be set to check for the word success in the test returned from a url
-
standard (default) - site, database and migrations checks are run plus email if settings have been changed
-
all / full - all checks are run
-
database - checks that the current migration level can be read from the database
-
email - basic check of email - :test returns true, :sendmail checks file is present and executable, :smtp sends HELO command to server and checks response
-
migration - checks that the database migration level matches that in db/migrations
-
site - checks rails is running sufficiently to render text
-
Fork the project.
-
Make your feature addition or bug fix.
-
Add tests for it. This is important so I don’t break it in a future version unintentionally.
-
Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
-
Send me a pull request. Bonus points for topic branches.
Copyright © 2010-2013 Ian Heggie, released under the MIT license. See MIT-LICENSE for details.
-
No inline documentation for methods
-
Feedback welcome especially with suggested replacement code and corresponding tests
-
fitter_happier plugin by atmos - plugin with similar goals, but not compatible with uptime, and does not check email gateway
See Travis CI testing result: <img src=“https://travis-ci.org/ianheggie/health_check.png” />
-
0.x - Rails 2.3
-
1.x - Includes Rails 3.x suppprt as an Engine
-
1.0.2 - Included travis config and gemfiles used in travis tests in gem and changes to test setup so that gem test