monit-general
[Top][All Lists]
Advanced

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

Re: Restarting process based on log file match


From: Martin Pala
Subject: Re: Restarting process based on log file match
Date: Mon, 13 Oct 2014 12:01:11 +0200

Hello,

if the process is monitored by monit as well, clean configuration may look like 
this:

--8<--
check process myprocess with pidfile ...
    start program = "/etc/init.d/my_service start"
    stop program = "/etc/init.d/my_service stop"
    restart program = "/etc/init.d/my_service restart"

check file myfile with path ...
    if matched "FOOBAR" then exec "/usr/bin/monit restart myprocess"
--8<--

The "PID changed" event is triggered if the monitored process was restarted out 
of monit control - in this case the start/stop script was executed via exec 
action which has no relationship with the process check itself (monit doesn't 
analyze the exec action command), hence it seemed the process was restarted 
externally. Using "monit restart myprocess" is clear request to restart the 
process. Monit doesn't support actions with references to other services, so 
the workaround is to use the exec action.

The restart problem itself may be related to monit < 5.9 on some platforms ... 
the Monit 5.9 and newer should work fine.

Regards,
Martin


On 10 Oct 2014, at 17:29, Alain Kreienbuhl <address@hidden> wrote:

> Hello,
> 
> I'm try to restart a process based on a file match 
> 
> in the check file a added 
>   start program = "/etc/init.d/my_service start"
>   stop program = "/etc/init.d/my_service stop"
>   
> Somehow the start never really happened
> 
> [CEST Oct 10 17:09:35] info     : 'my_service-log' trying to restart
> [CEST Oct 10 17:09:35] info     : 'my_service-log' stop: 
> /etc/init.d/my_service
> [CEST Oct 10 17:09:35] info     : 'my_service-log' start: 
> /etc/init.d/my_service
> [CEST Oct 10 17:10:35] error    : 'my_service' process is not running
> [CEST Oct 10 17:10:36] info     : 'my_service' trying to restart
> [CEST Oct 10 17:10:36] info     : 'my_service-log' stop: 
> /etc/init.d/my_service
> [CEST Oct 10 17:10:36] info     : 'my_service' start: /etc/init.d/my_service
> 
> I removed the start/stop program declaration and used 
> exec "/etc/init.d/{{app[0]}} restart"
> instead of 
> restart 
> 
> Now I'm getting  process PID changed from 31350 to 31473  alert (with I can 
> live with)
> 
> Is this the way to go ? 
> 
> Thanks 
> 
> Alain
> 
> --
> To unsubscribe:
> https://lists.nongnu.org/mailman/listinfo/monit-general




reply via email to

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