在认为某事已死之前让 monit 等待更长时间

Ram*_*yag 20 monit

我正在尝试启动一个程序 (Resque),但在写入 pidfile 之前需要一些时间。因此,我认为 Monit 认为程序尚未启动,并在写入第一个 pidfile 之前再启动一两个程序。

我如何延迟 Monit 再次检查的时间,只是为了这个过程?或者我应该以另一种方式解决这个问题?

eww*_*ite 19

您可以在与默认时间不同的时间间隔内检查特定服务...

请参阅Monit 文档中的服务轮询时间

您的 Resque 程序的一个示例是检查不同数量的循环:

check process resque with pidfile /var/run/resque.pid
   every 5 cycles
Run Code Online (Sandbox Code Playgroud)

或从示例部分:

Some servers are slow starters, like for example Java based Application Servers. 
So if we want to keep the poll-cycle low (i.e. < 60 seconds) but allow some services to take its time to start, 
the every statement is handy:

 check process dynamo with pidfile /etc/dynamo.pid every 2 cycles
       start program = "/etc/init.d/dynamo start"
       stop program  = "/etc/init.d/dynamo stop"
       if failed port 8840 then alert
Run Code Online (Sandbox Code Playgroud)

或者您可以利用 cron 样式的检查。

check process resque with pidfile /var/run/resque.pid
   every 10 * * * *
Run Code Online (Sandbox Code Playgroud)

或者,如果您遇到启动缓慢的问题,您可以在 service start 命令中延长超时时间:

check process apache with pidfile /var/run/httpd.pid
       start program = "/etc/init.d/httpd start" with timeout 90 seconds
Run Code Online (Sandbox Code Playgroud)

  • “超时 90 秒”正是我想要的。谢谢。 (2认同)

kaj*_*aji 11

我如何延迟 Monit 再次检查的时间,只是为了这个过程?


您想要实现的目标可以通过monit 的“ SERVICE POLL TIME ”功能完成

监控文件说

定期检查服务由

set daemon n
Run Code Online (Sandbox Code Playgroud)

陈述。检查的执行顺序与它们在 .monitrc 文件中写入的顺序相同,除非在服务之间设置了依赖关系,在这种情况下,服务层次结构可能会改变检查的顺序。

自定义服务轮询的方法之一是

  1. 基于轮询周期长度倍数的自定义间隔

每 [number] 个周期

例子:

check process resque with pidfile /your/app/root/tmp/pid/resque.pid
   every 2 cycles
Run Code Online (Sandbox Code Playgroud)

或者我应该以另一种方式解决这个问题?


我还最初尝试使用 monit 来监控 resque 作业,因为 monit 是一个非常轻量级的守护进程,但最终还是被 GOD 解决了。我知道,我知道与 monit 相比,GOD 更需要资源,但在 resque 的情况下,我们发现它是一个很好的匹配。


Vai*_*den 9

您还可以检查是否连续 X 次失败:

 if failed 
    port 80 
    for 10 cycles 
 then alert
Run Code Online (Sandbox Code Playgroud)

或者在 Y 轮投票中 X 次:

 if failed 
    port 80
    for 3 times within 5 cycles 
 then alert
Run Code Online (Sandbox Code Playgroud)

或两者:

 check filesystem rootfs with path /dev/hda1
  if space usage > 80% for 5 times within 15 cycles then alert
  if space usage > 90% for 5 cycles then exec '/try/to/free/the/space'
Run Code Online (Sandbox Code Playgroud)

从这里