Monitoring CouchDB with monit

CouchDB is a very good NoSQL database and has many interfaces for many languages. Sometimes however, in low resource environments it can fail and your applications are then doomed to fail as well.

One way to make the operation of your couchdb service behave is to use monit to monitor the service and restart it if necessary.

For this, I use the following monit directives (located in monitrc) that seem to work well in a debian based system:

#################################################################
# couchdb
################################################################

check process couchdb
  with pidfile /var/run/couchdb/couchdb.pid
  start program = "/etc/init.d/couchdb start"
  stop program = "/etc/init.d/couchdb stop"
  if failed host localhost port 5984 proto http then restart
  if failed url http://localhost:5984/ and content == '"couchdb"' then restart
  if 3 restarts within 5 cycles then timeout
group couchdb

For more information on monit click here. For couchdb click here.