我已将monit配置为检查我的IRCd及其服务是否正在运行。最近运行所有这些的实例重新启动,并且它没有完成它的工作。
它被配置为在启动时启动。
[root@ip-172-31-21-162 ec2-user]# chkconfig --list monit
monit 0:off 1:off 2:on 3:on 4:on 5:on 6:off
控制文件
[root@ip-172-31-21-162 ec2-user]# cat /etc/monit.conf
set httpd port 2812
allow 127.0.0.1
set daemon 60
include /etc/monit.d/*
check process ircd with pidfile /home/ec2-user/inspircd/run/pid
start program = "/usr/bin/perl /home/ec2-user/inspircd/run/inspircd start"
as uid "ec2-user" and gid "ec2-user"
with timeout 30 seconds
check process services with pidfile /home/ec2-user/anope/run/data/services.pid
depends on ircd
start program = "/bin/sh /home/ec2-user/anope/run/bin/anoperc start"
as uid "ec2-user" and gid "ec2-user"
with timeout 30 seconds
根据文档......
,这种语法看起来没问题<START | STOP | RESTART> [PROGRAM] = "program"
[[AS] UID <number | string>]
[[AS] GID <number | string>]
[[WITH] TIMEOUT <number> SECOND(S)]
对它进行检查说的是相同的
[ec2-user@ip-172-31-29-142 ~]$ sudo monit -t
Control file syntax OK
日志显示,这些受监视进程的启动方法尚未定义!
[UTC May 14 04:39:51] error : 'ircd' process is not running
[UTC May 14 04:39:51] error : monit: Start or stop method not defined -- process ircd
[UTC May 14 04:39:51] error : 'services' process is not running
[UTC May 14 04:39:51] error : monit: Start or stop method not defined -- process services
出于某种原因,通过monit手动启动进程
[root@ip-172-31-21-162 ec2-user]# monit start ircd
[root@ip-172-31-21-162 ec2-user]# monit status
The Monit daemon 5.2.5 uptime: 7h 14m
Process 'ircd'
status running
monitoring status monitored
pid 26483
parent pid 1
uptime 3m
...
data collected Sat May 14 02:49:57 2016
Process 'services'
status running
monitoring status monitored
pid 26488
parent pid 1
uptime 3m
...
data collected Sat May 14 02:49:57 2016
这很奇怪。当我停止那些检查过程并重启monit并启用调试日志记录时,我看到它报告了启动程序。
Process Name = ircd
Pid file = /home/ec2-user/inspircd/run/pid
Monitoring mode = active
Start program = '/home/ec2-user/inspircd/run/inspircd start' as uid 500 as gid 500 timeout 30 second(s)
Existence = if does not exist 1 times within 1 cycle(s) then restart else if succeeded 1 times within 1 cycle(s) then alert
Pid = if changed 1 times within 1 cycle(s) then alert
Ppid = if changed 1 times within 1 cycle(s) then alert
Process Name = services
Pid file = /home/ec2-user/anope/run/data/services.pid
Monitoring mode = active
Start program = '/home/ec2-user/anope/run/bin/anoperc start' as uid 500 as gid 500 timeout 30 second(s)
Existence = if does not exist 1 times within 1 cycle(s) then restart else if succeeded 1 times within 1 cycle(s) then alert
Depends on Service = ircd
Pid = if changed 1 times within 1 cycle(s) then alert
Ppid = if changed 1 times within 1 cycle(s) then alert
知道Glob的名字在这里发生了什么吗?
答案 0 :(得分:0)
根据记录的monit行为,还必须定义一个停止方法,以便正确启动非正常运行的进程
在主动模式(默认设置)下,Monit将主动监控服务,并在出现问题时发出警报和/或重新启动服务。
Monit在进程未运行时执行的操作始终是“重启”,但由于没有独立的“重启程序”(直到Monit 5.7),因此使用了停止+启动顺序。
- Monit issues; restart instead of start when a process is not running
因此,解决方案是将stop program
行添加到控制文件中的已检查进程。显然,如果您运行的是版本&gt; = 5.7,则可以使用restart program