What does Monit do when it says 'initializing'?

6

1

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

Posted 2010-12-08T10:16:04.873

Reputation: 163

Answers

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.

LawrenceC

Posted 2010-12-08T10:16:04.873

Reputation: 63 487

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 – 2010-12-08T13:41:17.193

Does the service take that long to create a .pid file? IIRC Monit needs that to verify the service is running. – LawrenceC – 2010-12-08T21:18:29.173

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 – 2010-12-10T13:51:53.707

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

Taylor Brockman

Posted 2010-12-08T10:16:04.873

Reputation: 11