Linux
Monit:ping 一個網站 url 然後重啟應用伺服器
我正在使用這個配置來監控 apache2(ubuntu):
/etc/monit/conf.d/apache2:
check process apache with pidfile /var/run/apache2/apache2.pid start program = "/etc/init.d/apache2 start" with timeout 60 seconds stop program = "/etc/init.d/apache2 stop" alert f.bozzo@3-w.it with mail-format { from: monit@3-w.it subject: monit alert: $SERVICE $EVENT $DATE message: $DESCRIPTION } if failed port 80 protocol HTTP request / with timeout 7 seconds then restart
訪問 ‘request /’ 會導致 ubuntu-apache 預設頁面:如果您可以訪問它,那麼 Apache 正在工作。沒關係。
現在我也需要監控我的應用伺服器。所以我有第二個配置文件:
check process lucee with pidfile /opt/lucee/tomcat/work/tomcat.pid start program = "/etc/init.d/lucee_ctl start" with timeout 60 seconds stop program = "/etc/init.d/lucee_ctl stop"
我不知道如何告訴 monit 請求完全限定的 URI,我需要類似的東西
if failed port 80 protocol HTTP request http://www.xxxxxx123123.com/ with timeout 7 seconds then restart
但那說
/etc/monit/conf.d/lucee:13:錯誤:語法錯誤’
在重新載入。任何的想法?
基於樣本
if failed host localhost port 80 with protocol http and request "/server-status" with timeout 25 seconds for 4 times within 5 cycles then restart
試著把
if failed host www.xxxxxx123123.com port 80 with protocol http and request "/" with timeout 7 seconds then restart