我正在尝试设置 Monit,以便在 PHP 崩溃时跟踪域。示例:
check file php7.3-fpm-pidfile with path /var/run/php/php7.3-fpm.pid
start program = "/usr/sbin/service php7.3-fpm start" with timeout 60 seconds
stop program = "/usr/sbin/service php7.3-fpm stop"
if does not exist then restart
if failed unixsocket /run/php/php7.3-fpm-domain.co.uk.sock then restart
if failed unixsocket /run/php/php7.3-fpm-domain2.co.uk.sock then restart
if failed unixsocket /run/php/php7.3-fpm-domain3.co.uk.sock then restart
作为一个简单的测试:
check file php7.3-fpm-pidfile with path /var/run/php/php7.3-fpm.pid
start program = "/usr/sbin/service php7.3-fpm start" with timeout 60 seconds
stop program = "/usr/sbin/service php7.3-fpm stop"
if does not exist then restart
if failed unixsocket /run/php/php7.3-fpm-domain.co.uk.sock then restart
然而,重新启动Monit时最终失败:
/etc/monit/conf-enabled/php-fpm:14:语法错误“unixsocket”
我上线了Monit 5.31.0,它应该足够新,才有这个unixsocket
选项。我遗漏了什么?
答案1
你确定你会检查一个文件吗?从我的角度来看,你会检查一个过程吗?
我建议检查 unixsocket 和进程:
check process php7.3-fpm-pidfile with path /var/run/php/php7.3-fpm.pid
start program = "/usr/sbin/service php7.3-fpm start" with timeout 60 seconds
stop program = "/usr/sbin/service php7.3-fpm stop"
if does not exist then restart
if failed unixsocket /run/php/php7.3-fpm-domain.co.uk.sock then restart
您不能在所有检查中使用所有可用的测试(“if”语句)。
monit -v -t
Process Name = php7.3-fpm-pidfile
Pid file = /var/run/php/php7.3-fpm.pid
Monitoring mode = active
On reboot = start
Start program = '/usr/sbin/service php7.3-fpm start' timeout 1 m
Stop program = '/usr/sbin/service php7.3-fpm stop' timeout 30 s
Existence = if does not exist then restart
Unix Socket = if failed /run/php/php7.3-fpm-domain.co.uk.sock type TCP protocol DEFAULT with timeout 5 s then restart
手册中的片段,请参阅https://www.mmonit.com/monit/documentation/monit.html
连接测试
Monit 可以通过网络端口或 Unix 套接字执行连接测试。连接测试只能在进程或主机服务类型上下文中使用。
连接测试仅适用于进程或主机服务。