ubuntu - Tomcat:/etc/init.d/tomcat 不存在且 monit 不起作用
问题描述
我试图在 ubuntu 中使用 tomcat 构建监视器,但我有两个问题。
我找不到 pid 文件,并且“/etc/init.d/tomcat”不存在
我该怎么做?
这是我在监控中的代码:
check process tomcat with pidfile "/var/run/tomcat/tomcat.pid"
start program = "/usr/local/tomcat/bin/startup.sh" as uid tomcat gid tomcat
stop program = "/usr/local/tomcat/bin/shutdown.sh" as uid tomcat gid tomcat
if failed port 8080 then alert
if failed port 8080 for 5 cycles then restart
谢谢!
解决方案
- 无论配置如何,Tomcat 似乎都不会创建 pidfile。有关如何说服 Tomcat 创建一个的提示,请参阅此要点。
- 如果您使用的是 Ubuntu >= 15.04,您应该已经
systemd
在场(请参阅此 wiki 条目)。因此开始/停止应该是systemctl start tomcat
和systemctl stop tomcat
(或tomcat.service
)。
如果你不能让你的 Tomcat 创建一个 pidfile,你也可以使用匹配而不是一个 pidfile(但我总是推荐一个 pidfile!)。
其余的似乎还可以,但有一点限制:如果您开始使用systemctl
启动/停止服务,则需要具有超级用户权限才能这样做。你比省略as uid tomcat gid tomcat
.start/stop program
编辑 2019-11-02, 14:00 UTC:
我的配置看起来像这样:
check process tomcat with pidfile "/var/run/tomcat/tomcat.pid"
start program = "/bin/systemctl start tomcat.service"
stop program = "/bin/systemctl stop tomcat.service"
if failed port 8080 then restart
if 3 restarts within 5 cycles then unmonitor
推荐阅读
- excel - VBA Excel 连接刷新 - 运行时 91 错误
- c# - “System.Array”不包含“Capacity”的定义 - C#
- contiki - Contiki/Cooja 如何从套接字(串行套接字(服务器/客户端))读取数据(在模拟节点中)
- php - 选择表中日期介于同一表中另一行中的 2 个日期之间的行
- html - 图库在移动视图中消失
- slurm - 在同一个节点上运行两个脚本
- excel - 如果 2 个单元格为空,则执行 if 语句,如果第 3 个单元格不为空,则执行 if 语句
- django - 覆盖的 delete() 方法不适用于 django admin 的所有部分
- oracle - AWS DMS - 迁移 Oracle 数据库时任务失败
- sql - 计算一个带有条件的选择