[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: check process with delay

From: Martin Pala
Subject: Re: check process with delay
Date: Wed, 29 Oct 2014 08:33:18 +0100

Clean way to prevent any race conditions is to use the monitor/unmonitor 
commands ... you can add it directly to your stop/start init script for the 
given service. Relying on pre-configured pause doesn't guarantee that the 
update will be finished in time and if the update was for some reason slow or 
stopped and pause will pass, then the Monit will try to restart the process.


> On 29 Oct 2014, at 05:12, Do <address@hidden> wrote:
> Thanks much, Martin!
> I didn't realize that it's possible to override default action in such way. 
> This is great!
> About idea with stopping monitoring this is not possible since updates are 
> automatic decision by 3rd party system.
> Third idea I think of, is to let Monit sense that service is 
> 'administratively stopped' by `init.d/service stop` and not restart in that 
> case. This is possible in Centos, since their init scripts usually create 
> `/var/lock/subsys/servicename` file when service is started from init.d 
> scripts and `rm` that file when stopped. Thus, it's theoretically possible to 
> distinguish situation when service is died and not normally stopped. (This is 
> sort of what condrestart do.) Example, how I envision it:
> check process exim with pidfile /var/spool/exim/
>  if does not exists for 5 cycles then start 
>  # 5 cycles since administrative stop can be slow
>  start   "/sbin/service exim start"
>  depend exim.subsys
> check file exim.subsys /var/lock/subsys/exim noalert address@hidden
> But I think (from reading docs) Monit will just 'unmonitor' exim.subsys if 
> `/var/lock/subsys/exim` does not exists, so if it reappears nothing will 
> happen. Which is not what I need. Maybe there is proper way to do that sort 
> of checking?
> Would be cool just to write 'depend on file /var/lock/subsys/exim' in 'check 
> process' statement, to make it only work when no `/var/lock/subsys/exim` 
> exists. Yes, that case will prevent service start after reboot, which is 
> tolerable or even desired in case of Monit used only as watchdog. (Sorry, 
> feature request again. :)
> Thanks,
> Don.
> 28.10.2014, 17:39, "Martin Pala" <address@hidden>:
>> Hello,
>> you can disable the monitoring before your update begins and enable it again 
>> when it stops:
>>         1.) monit unmonitor exim
>>         2.) perform exim update / deploy application
>>         3.) monit monitor exim
>> If you need to delay the implicit restart if the process stopped, you can 
>> override the default action:
>> --8<--
>> check process exim with pidfile /var/spool/exim/
>>         if does not exist for 10 cycle then restart
>> --8<--
>> Regards,
>> Martin
>>>  On 28 Oct 2014, at 15:21, Do <address@hidden> wrote:
>>>  Hello,
>>>  Many people, like me, have host management systems (like cPanel), that 
>>> when doing periodic system update can temporary stop/start services on its 
>>> own. But I still want Monit to watch services. So I need Monit to lag a bit 
>>> for its checks, thus making it always slower than quick service stop/start 
>>> when system is updated. But I don't see suitable options in Monit config.
>>>  For example, If I have
>>>  check process exim with pidfile /var/spool/exim/
>>>   every 10 cycles
>>>   start   "/sbin/service exim start"
>>>  (where cycle=1minute), this does not guarantee that Exim is permitted to 
>>> be down for 10 minutes. It could happen than Monit just reached 10th cycle 
>>> seconds before Exim is stopped. As consequence Exim will be started in the 
>>> middle or stopping or updating.
>>>  Can we have something like 'for 10 cycles [then start]' option added for 
>>> 'every 1 cycle' statement? (Feature request.)
>>>  Thanks,
>>>  Don.
>>>  --
>>>  To unsubscribe:
>> --
>> To unsubscribe:
> --
> To unsubscribe:

reply via email to

[Prev in Thread] Current Thread [Next in Thread]