我正在使用此配置来监控 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 [email protected] with mail-format {
from: [email protected]
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:错误:语法错误'
重新加载。有什么想法吗?
答案1
根据样本
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