结合卸载,停止,安装,通过monit启动脚本

我们有监听端口9000的套接字监听器,下面是我们如何编写monit的警报。 侦听器通过yajsw守护进程工具运行。 所以目前当它在9000端口失败时,我们会收到一封电子邮件。 我们想要扩展的是,如果它没有停止运行,卸载,安装并最终启动程序。 我们有所有的脚本到所述的过程,但如何把监视? 所有这些都在shell脚本文件中。

check process cs9000 with pidfile /var/run/wrappercs9000.pid # check your app pid start program = stop program = if failed port 9000 # if you want to check your app that listen on port 9000 then restart 

使用Monit ,在您提供start programstop program指令之前,您将无法重新start program 。 当您填充这些选项并重新启动Monit时,您将获得根据stream程条件采取行动的能力。

一个例子:

 check process nslcd with pidfile "/var/run/nslcd/nslcd.pid" start program = "/sbin/service nslcd start" stop program = "/sbin/service nslcd stop" if 10 restarts within 11 cycles then timeout if cpu usage > 95% for 11 cycles then restart if totalmemory > 472 MB then restart 

如果您希望“停止程序”运行脚本,请提供脚本的完整path。