RHEL - ntpd: Monit tries to restart ntpd while it is running

Issue #587 closed
Former user created an issue

We're using monit-5.4-1.x86_64 on a RHEL 6.5 system, manging ntpd with the following entry in the monitrc - file:

check process ntpd with pidfile /var/run/ntpd.pid
    start program = "/etc/init.d/ntpd start"
    stop program  = "/etc/init.d/ntpd stop"
    if failed host 127.0.0.1 port 123 type udp then restart
    if 5 restarts within 5 cycles then timeout

...it seems monit does not realize really that ntpd is running already as we see the following in the /var/log/messages:

monit[9875]: 'ntpd' process is not running
monit[9875]: 'ntpd' trying to restart
monit[9875]: 'ntpd' start: /etc/init.d/ntpd
ntpd[43748]: ntpd 4.2.6p5@1.2349-o Mon Jul 15 09:22:49 UTC 2013 (1)
ntpd[43749]: proto: precision = 0.067 usec
ntpd[43749]: 0.0.0.0 c01d 0d kern kernel time sync enabled
ntpd[43749]: unable to bind to wildcard address 0.0.0.0 - another process may be running - EXITING
monit[9875]: 'ntpd' failed to start
monit[9875]: 'ntpd' service restarted 5 times within 5 cycles(s) - unmonitor

Comments (2)

  1. Tildeslash repo owner

    If monit didn't found the process is running, the problem is in the pidfile content (/var/run/ntpd.pid), which is not updated by the start script properly and doesn't match the running ntpd process.

    You can use the process pattern instead of pidfile, for example:

    check process ntpd matching "ntpd"
        start program = "/etc/init.d/ntpd start"
        stop program  = "/etc/init.d/ntpd stop"
        if failed host 127.0.0.1 port 123 type udp then restart
        if 5 restarts within 5 cycles then timeout
    

    We strongly recommend to update monit as the pattern base process check had many improvements since Monit 5.4 (https://mmonit.com/monit/#download)

  2. Log in to comment