【问题标题】:Restart monit automatically after it has been killed by the systemmonit 被系统杀死后自动重启
【发布时间】:2016-09-07 21:11:59
【问题描述】:

我正在使用 monit 来监控我的 WEB 服务。一切正常,直到监控进程被系统杀死。 monit 日志文件的一部分显示了该问题

为了让 monit 在启动时自动启动并在失败时重新启动,我为 monit 添加了 upstart 配置(我运行的是 Ubuntu 14.04),如下所示:

    # This is an upstart script to keep monit running.
    # To install disable the old way of doing things:
    #
    #   /etc/init.d/monit stop && update-rc.d -f monit remove
    #
    # then put this script here:
    #
    #   /etc/init/monit.conf
    #
    # and reload upstart configuration:
    #
    #   initctl reload-configuration
    #
    # You can manually start and stop monit like this:
    # 
    # start monit
    # stop monit
    #

    description "Monit service manager"

    limit core unlimited unlimited

    start on runlevel [2345]
    stop on starting rc RUNLEVEL=[016]

    expect daemon
    respawn

    exec /usr/bin/monit -c /etc/monitrc

    pre-stop exec /usr/bin/monit -c /etc/monitrc quit

当我重新启动系统时,monit 没有运行。

    sudo monit status
    $ monit: Status not available -- the monit daemon is not running

如何配置 upstart 以保持监控运行和监控?

【问题讨论】:

    标签: monitoring upstart monit


    【解决方案1】:

    我在 start monit 命令中的配置文件路径错误。正确的命令是

        exec /usr/bin/monit -c /etc/monit/monitrc
    
        pre-stop exec /usr/bin/monit -c /etc/monit/monitrc quit
    

    它作为守护进程启动 monit 并在我杀死它时重新启动:

        ps aux | grep monit
        root      2173  0.0  0.1 104348  1332 ?        Sl   04:13   0:00 /usr/bin/monit -c /etc/monit/monitrc
    
        sudo kill -9 2173
    
        ps aux | grep monit
        root      2184  0.0  0.1 104348  1380 ?        Sl   04:13   0:00 /usr/bin/monit -c /etc/monit/monitrc
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多