Monit Service Monitoring

Monit is used by default on the Brightboxes to monitor the status of services, such as your Rails apps or Apache. It also monitors disk usage and gives a warning if the disk is approaching full.

The Brightbox Capistrano GEM uses Monit to manage the Mongrel processes entirely, starting, stopping and restarting.

Basic usage

Getting the status of services

sudo monit status

Restarting a service

If you want to just restart one process, say one of the mongrels set up by the Brightbox GEM:

sudo monit restart mongrel_myapp_9221

Restarting a group of services

If you want to restart all mongrels for a particular app, you can restart all processes in a particular group. The Brightbox GEM puts all the mongrels for each app in a group named after the app:

sudo monit -g myapp restart all

Email Alerts

Monit is preconfigured with your signup email address and will send email notifications out when it's state changes, such as when a service went down and needed restarting, or when Monit was reloaded.

You can change this email address by editing the file /etc/monit/conf.d/email-alerts.monitrc on your Brightbox then reloading monit:

sudo pico /etc/monit/conf.d/email-alerts.monitrc
sudo /etc/init.d/monit restart

Default config bug

One of our default configs for Monit has a bug where the memory limit is set too low and Monit restarts the Rails app too often. You'll receive lots of emails from Monit saying “Resource limit matched”. We'll be rolling out a new Gem soon to fix this, but you can fix it yourself in the mean time:

To fix this, edit your apps Monit config:

sudo pico /etc/monit/conf.d/rails-yourappname.monitrc

And find any lines like this:

if totalmem > 110 Mb then restart

And change them to this:

if mem > 110 Mb then restart

Then reload monit:

sudo monit reload

That will allow each of your mongrels to grow up to 110Mb before being restarted. This is quite high but is a useful default for protecting again a serious memory leak - tweak this figure to whatever suits your needs best.

docs/monit.txt · Last modified: 2009/05/08 17:04 (external edit)