
我正在嘗試設定 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'
我上線了監控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 套接字執行連線測試。連線測試只能在進程或主機服務類型上下文中使用。
連線測試僅適用於進程或主機服務。