Skip to content

Instantly share code, notes, and snippets.

@durran
Created December 1, 2011 14:14
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save durran/1417023 to your computer and use it in GitHub Desktop.
Save durran/1417023 to your computer and use it in GitHub Desktop.
MongoDB Monit Config
check process mongodb
with pidfile "/var/lib/mongodb/mongod.lock"
start program = "/sbin/start mongodb"
stop program = "/sbin/stop mongodb"
if failed port 28017 protocol http
and request "/" with timeout 10 seconds then restart
if 5 restarts within 5 cycles then timeout
@geddski
Copy link

geddski commented Mar 23, 2012

like it. Thanks

@hyperrjas
Copy link

I have my mongodb database in other server. This is my monit file:

check process mongodb
  with pidfile "/var/lib/mongodb/mongod.lock"
  start program = "/sbin/start mongodb"
  stop program = "/sbin/stop mongodb"
  if failed host 111.111.111.111 port 28017 protocol http
    and request "/" with timeout 10 seconds then restart
  if 5 restarts within 5 cycles then timeout

However I get Execution failed or Not monitored.

Thank you!

@okazdal
Copy link

okazdal commented Mar 12, 2014

Are you sure about pidfile here?
On my ubuntu server, mongodb installed from 10gen repo, pidfile location is /var/run/mongodb.pid

@WyskyNet
Copy link

I had same issue like above - Monit cannot read mongod.lock file...

So I moddified config and this one works for me:

check process mongod matching "/usr/bin/mongod"
   group database
   start program = "/sbin/start mongod"
   stop  program = "/sbin/stop mongod"
   if failed host 127.0.0.1 port 27017 protocol http
     and request "/" with timeout 10 seconds then restart
   if 5 restarts within 5 cycles then timeout

(Ubuntu 14.04, MongoDb 2.6.6, Monit 5.6)

@madhavkaneriya
Copy link

What to do if my MongoDb is authenticated ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment