Search code examples
monitapplication-monitoring

When will monit actually start or restart a service


Can someone please let me know on what basis monit decides that its time to restart an application? For instance, if I want monit to monitor my web application, what information should I provide to monit based on which it will restart?

thanks

Update: I was able to kind of make it work using the following monit config

check host altamides with address web.dev1.ams
if failed port 80 with protocol http
      then alert

However, I was wondering if I can use any absolute URL of my application. Something like http://foo:5453/test/url/1.html/

Can someone help me on that please?


Solution

  • Monit by himself will not restart any service, but you can provide to it the rules you want to perform it, you can do something like

    check process couchdb with pidfile /usr/local/var/run/couchdb/couchdb.pid
        start program = "/etc/init.d/couchdb start"
        stop program  = "/etc/init.d/couchdb stop"
        if cpu > 60% for 2 cycles then alert
        if cpu > 80% for 5 cycles then restart
        if memory usage > 70% MB for 5 cycles then restart
    
    
    check host mmonit.com with address mmonit.com
          if failed port 80 protocol http then alert
          if failed port 443 protocol https then alert