monit监控tomcat service

本文介绍如何使用Monit监控Tomcat服务,并在服务不可用时自动重启。具体步骤包括安装Monit、配置监控规则及启动Monit服务。监控项包括健康检查URL响应情况等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

利用monit对tomcat进行监控,在服务不可用的时候对tomcat进行重启。

1.安装monit

# apt-get install monit

2.配置monit

在/etc/monit/conf.d目录下面,创建一个tomcatrc的文件,写入如下内容

  check host all  with address localhost
    start program = "/home/ubuntu/webservice/apache-tomcat-8.0.30/bin/startup.sh " with timeout 60 seconds
    stop program  = "/home/ubuntu/webservice/apache-tomcat-8.0.30/bin/shutdown.sh"
#    if cpu > 60% for 2 cycles then alert
#    if cpu > 80% for 5 cycles then restart
#    if totalmem > 200.0 MB for 5 cycles then restart
#    if children > 250 then restart
#    if loadavg(5min) greater than 10 for 8 cycles then stop
    if failed host localhost port 80 protocol http
       and request "/auto/health"
       then restart
#    if failed port 443 type tcpssl protocol http
#       with timeout 15 seconds
#       then restart
#    if 3 restarts within 5 cycles then timeout
#    depends on apache_bin
#    group server

上面主要是监控tomcat的服务,如果 /auto/health无法获得有效的数据,那么monit就会对服务进行重启。

3.启动、停止monit

# /etc/init.d/monit start | stop


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值