在过程恢复时监视呼叫执行



我想做的是以下内容:

  • 如果process-x失败(re re),则执行CMD-X
  • 如果恢复,则执行CMD-Y

对于通过电子邮件发出警报,每默认恢复时发送了notificaton。但是,对于EXEC方法,我找不到一种方法来制作这项工作。如果我在monitrc中尝试一下:

check process proc_x with pidfile /var/run/proc_x.pid
   start program = "/bin/sh -c '/etc/init.d/Sxxproc_x start'"
   stop  program = "/bin/sh -c '/etc/init.d/Sxxproc_x stop'"
   if 3 restarts within 5 cycles then exec "<some error cmd>"
   else if succeeded then exec "<some restore cmd>"

这将导致" 语法错误'else'"。如果我删除其他行,则会按预期调用错误命令。显然,"其他"不能用于重新启动测试。但是如何添加以执行命令是启动程序成功或恢复?

我找到了一个解决方案,这要归功于此主题的答案:

让monit首先提醒并稍后重新启动

" 如果不存在... ", else "为我报告了恢复的技巧。错误报告是独立的。我的monitrc代码现在:

check process proc_x with pidfile /var/run/proc_x.pid
   start program = "/bin/sh -c '/etc/init.d/Sxxproc_x start'"
   stop  program = "/bin/sh -c '/etc/init.d/Sxxproc_x stop'"
   if 1 restart within 1 cycle then exec "<some error cmd>"
       repeat every 1 cycle
   if not exist for 3 cycles then restart
   else if succeeded 2 times within 2 cycles then exec "<some restore cmd>"

最新更新