monit 何时实际启动或重新启动服务

问题描述

有人可以告诉我 monit 是根据什么决定重启应用程序的吗?例如,如果我想让 monit 监控我的 Web 应用程序,我应该向 monit 提供哪些信息,根据哪些信息会重新启动?

谢谢

更新: 我能够使用以下 monit 配置使其工作

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

但是,我想知道是否可以使用我的应用程序的任何绝对 URL。类似于 http://foo:5453/test/url/1.html/

有人可以帮我吗?

解决方法

Monit 本身不会重启任何服务,但是你可以给它提供你想要执行它的规则,你可以做类似的事情

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
,

我从 monit 帮助页面找到了答案

 if failed
    port 80
    protocol http
    request "/data/show?a=b&c=d"
 then restart