解决Monit启动监控进程消失monit.service failed.

Monit监控软件启动时无法启动监控。

解决Monit启动监控进程消失monit.service failed.

Monit启动监控进程消失提示monit.service failed.

CWP控制面板(CWP7)安装Monit监控软件后,Monit启动监控进程消失,出现提示:monit.service failed.

值得注意的是,已经尝试启用过了systemctl enable monit

[root@stage-web-1 vagrant]# systemctl status monit
monit.service - Pro-active monitoring utility for unix systems
Loaded: loaded (/usr/lib/systemd/system/monit.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Thu 2017-06-01 16:37:00 UTC; 6min ago
Process: 1131 ExecStop=/usr/bin/monit quit (code=exited, status=1/FAILURE)
Process: 1079 ExecStart=/usr/bin/monit -I (code=exited, status=1/FAILURE)
Main PID: 1079 (code=exited, status=1/FAILURE)

Jun 01 16:37:00 stage-web-1 systemd[1]: Started Pro-active monitoring utility for unix systems.
Jun 01 16:37:00 stage-web-1 systemd[1]: Starting Pro-active monitoring utility for unix systems...
Jun 01 16:37:00 stage-web-1 monit[1079]: Error opening the log file '/var/www/html/nfs/monit/stage-web-1.log' for writing -- No such file or directory
Jun 01 16:37:00 stage-web-1 systemd[1]: monit.service: main process exited, code=exited, status=1/FAILURE
Jun 01 16:37:00 stage-web-1 monit[1131]: Error opening the log file '/var/www/html/nfs/monit/stage-web-1.log' for writing -- No such file or directory
Jun 01 16:37:00 stage-web-1 systemd[1]: monit.service: control process exited, code=exited status=1
Jun 01 16:37:00 stage-web-1 systemd[1]: Unit monit.service entered failed state.
Jun 01 16:37:00 stage-web-1 systemd[1]: monit.service failed.

事实说明,它/var/www/html/nfs是通过NFS安装到网络驱动器的文件夹。

Monit是在NFS之前启动的,因此该文件夹尚不存在,从而导致monit错误Error opening the log file '/var/www/html/nfs/monit/stage-web-1.log' for writing -- No such file or directory

如何解决Monit启动监控进程消失monit.service failed.?

解决方法是编辑/lib/systemd/system/monit.service

[Unit]
Description=Pro-active monitoring utility for unix systems
After=network.target

[Service]
Type=simple
ExecStart=/usr/bin/monit -I
ExecStop=/usr/bin/monit quit
ExecReload=/usr/bin/monit reload

[Install]
WantedBy=multi-user.target

并添加nfs.service到该After后面。最终结果如下所示:

[Unit]
Description=Pro-active monitoring utility for unix systems
After=network.target nfs.service

[Service]
Type=simple
ExecStart=/usr/bin/monit -I
ExecStop=/usr/bin/monit quit
ExecReload=/usr/bin/monit reload

[Install]
WantedBy=multi-user.target

Monit监控程序现在可以在启动时,成功启动了。

希望陈沩亮博客( https://www.chenweiliang.com/) 分享的《解决Monit启动监控进程消失monit.service failed.》,对您有帮助。

欢迎分享本文链接:https://www.chenweiliang.com/cwl-1422.html

最近陈沩亮博客刚开通了Telegram频道,而且已经将陈沩亮博客和Telegram频道实现了自动同步。

下次最新分享会第一时间自动同步到Telegram频道,欢迎订阅 ^_^

喜欢就分享和按赞!
您的分享和按赞,是我们持续的动力!

欲获取更多资讯内幕和秘技,欢迎扫码关注微信公众号:cwlboke
陈沩亮博客的 微信公众号二维码