Your polltime is set to 0 seconds:
--8<--
Poll time = 0 seconds
--8<--
This is set in monit control file either via 'set daemon' statement or
via the -d command line option.
In the case that the poll time is 0s, then monit never sleeps and
performs the testing loops immediately one after the other.
When monit performs service restart, it expects that the service will be
up and running next cycle (unless the 'every' statement is used which
allows to skip cycles). The timeout on service start is equal to poll
cycle length ... in your case 0s => service is expected to start
immediately.
Just let monit to sleep between cycles - good value is usually 5s,
depending on you needs ... for example: 'set daemon 5'
Martin
Thomas Johnson wrote:
I'm trying to use monit to monitor postfix, and I'm having trouble with
monit starting to monitor after the restart before postfix has really
had time to start up and write out it's pid file.
If I run monit after stopping postfix, it gets the pid from the pidfile,
and then properly sees that there's no such running process and sends a
notification. Then it starts the process, but it checks the OLD pid,
because the new one hasn't yet been written out to the file yet. It
sees that it didn't start, and sends out an "Execution failed" warning.
But a few seconds later, postfix is indeed running and working properly.
What am I doing wrong?
Here's output from monit -v Running 4.8.2
# monit -v
monit: Debug: Adding credentials for user 'admin'.
Runtime constants:
Control file = /usr/local/etc/monitrc
Log file = syslog
Pid file = /var/run/monit.pid
Debug = True
Log = True
Use syslog = True
Is Daemon = False
Use process engine = True
Poll time = 0 seconds
Mail server(s) = xxx
Mail from = xxx
Mail subject = monit alert -- $EVENT $SERVICE
Mail message = $EVENT Service $SERV..(truncated)
Start monit httpd = True
httpd bind address = Any/All
httpd portnumber = 2812
httpd signature = True
Use ssl encryption = False
httpd auth. style = Basic Authentication
Alert mail to = xxx
Alert on = All events
Process Name = postfix
Pid file = /var/spool/postfix/pid/master.pid
Monitoring mode = active
Start program = /etc/init.d/postfix-gw start
Stop program = /etc/init.d/postfix-gw stop
Pid = if changed 1 times within 1 cycle(s) then alert
Ppid = if changed 1 times within 1 cycle(s) then alert
Port = if failed localhost:10025 [SMTP via TCP] with
timeout 5 seconds 1 times within 1 cycle(s) then restart else if passed
1 times within 1 cycle(s) then alert
Port = if failed localhost:25 [SMTP via TCP] with
timeout 5 seconds 1 times within 1 cycle(s) then restart else if passed
1 times within 1 cycle(s) then alert
Timeout = If 5 restart within 5 cycles then unmonitor else
if passed then alert
-------------------------------------------------------------------------------
'postfix' Error testing process id [7861] -- No such process
'postfix' process is not running
Does not exist notification is sent to xxxx
'postfix' trying to restart
Monitoring disabled -- service postfix
'postfix' Error testing process id [7861] -- No such process
'postfix' Error testing process id [7861] -- No such process
'postfix' start: /etc/init.d/postfix-gw
'postfix' Error testing process id [7861] -- No such process
Monitoring enabled -- service postfix
'postfix' Error testing process id [7861] -- No such process
'postfix' failed to start
--
To unsubscribe:
http://lists.nongnu.org/mailman/listinfo/monit-general
--
To unsubscribe:
http://lists.nongnu.org/mailman/listinfo/monit-general