6

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.

10

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.

3
  • This line reads set daemon 10 with start delay 20 in my monitrc. But sometimes it stucks with 'initializing' for more than a minute. – mikezter Dec 8 '10 at 13:41
  • Does the service take that long to create a .pid file? IIRC Monit needs that to verify the service is running. – LawrenceC Dec 8 '10 at 21:18
  • 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. – mikezter Dec 10 '10 at 13:51
1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.