Yes, the uptime test can be used this way.

The process check will however alert if the process is not running - you can 
suppress this alert though: 
https://mmonit.com/monit/documentation/monit.html#Setting-an-event-filter 
<https://mmonit.com/monit/documentation/monit.html#Setting-an-event-filter>


Cheers,
Martin



> On 22 Aug 2019, at 19:28, David Jones via This is the general mailing list 
> for monit <[email protected]> wrote:
> 
> What if I wanted to check for something running too long?  I tried this and 
> it's alerting for not being present or for having less uptime.  Is it 
> possible to negate the alerting logic so it's OK when something is not 
> running or it's less that a certain age?
> 
> check process filter_grep_age matching filter_grep
>     if uptime > 7 hours then alert
> 
> This filter_grep command shouldn't run for more than a few hours or a user 
> has forgotten to stop it.
> 
> From: monit-general <[email protected] 
> <mailto:[email protected]>> on behalf of Lutz 
> Mader <[email protected] <mailto:[email protected]>>
> Sent: Thursday, August 22, 2019 1:29 AM
> To: This is the general mailing list for monit <[email protected] 
> <mailto:[email protected]>>
> Subject: Re: Check the age of a process
>  
> Hello Dave,
> a process uptime test ist available, see
> https://mmonit.com/monit/documentation/monit.html#UPTIME-TEST 
> <https://mmonit.com/monit/documentation/monit.html#UPTIME-TEST>
> 
> The uptime test is availabel for the process and system service
> definitions only.
> 
> > Example of restarting the process every three days:
> >
> >  check process myapp with pidfile /var/run/myapp.pid
> >     start program = "/etc/init.d/myapp start"
> >     stop program = "/etc/init.d/myapp stop"
> >     if uptime > 3 days then restart
> 
> With regards,
> Lutz
> 
> p.s.
> The test is available since some years (I find the test in Monit 5.16).
> Check the used Monit version with the command "monit -V".

Reply via email to