What does Monit do when it says 'initializing'?

6,601

Solution 1

If you look in /etc/monit/monitrc, you'll see one of the options is "set daemon" which controls how often Monit checks services. Mine is set at 120. So that is the quickest Monit will update what it reports. The script might return in 2 seconds, but if yours is set like mine Monit won't check it again for another 118 seconds thereafter.

Solution 2

Solved my monit initialization delay caused by a non-responsive SMTP mail server.

Commenting out these two lines in /etc/monit/monitrc were the isloated config change I applied to make my monit restarts really fast!

# set mailserver smtp.sendgrid.com
#  username "apikey" password "SG.."

These /var/log/monit.log entries helped:

[EDT Jun  9 06:28:32] error    : Cannot create socket
 to [smtp.sendgrid.com]:25 -- Connection timed out
[EDT Jun  9 06:28:32] error    : Cannot open a connection to the mailserver 'smtp.sendgrid.com:25' -- Operation now in progress
[EDT Jun  9 06:28:32] error    : Mail: No mail servers are available

monit -V

This is Monit version 5.16
Built with ssl, with pam and with large files
Copyright (C) 2001-2016 Tildeslash Ltd. All Rights Reserved.

lsb_release -a

Distributor ID: Ubuntu
Description:    Ubuntu 16.04.6 LTS
Release:    16.04
Codename:   xenial

uname -a

Linux prime3prod 4.4.0-1084-aws #94-Ubuntu SMP Fri May 17 13:10:20 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Share:
6,601

Related videos on Youtube

mikezter
Author by

mikezter

Updated on September 17, 2022

Comments

  • mikezter
    mikezter over 1 year

    I'm using Monit for system monitoring. If i enable monitoring on a service it shows 'initializing' in the Status row. This can take a while. I wonder what Monit is doing in that time, since the used start script should return in under 2 secs max.

  • mikezter
    mikezter over 13 years
    This line reads set daemon 10 with start delay 20 in my monitrc. But sometimes it stucks with 'initializing' for more than a minute.
  • LawrenceC
    LawrenceC over 13 years
    Does the service take that long to create a .pid file? IIRC Monit needs that to verify the service is running.
  • mikezter
    mikezter over 13 years
    Actually your answer pointed me into the right direction: The init script i used started monit with the command line parameter -d which overrides directives in the config file.