monit-general
[Top][All Lists]
Advanced

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

Re: Conditional check process?


From: Martin Pala
Subject: Re: Conditional check process?
Date: Wed, 23 Jul 2014 14:33:33 +0200

You can use independent file test which will control the process monitoring, 
something like:

--8<--
check process sidekiq_1 with pidfile /tmp/pids/sidekiq_1.pid
   start program = "/bin/bash -l -c 'bundle exec sidekiqctl start" as uid jim 
and gid jim with timeout 250 seconds
   stop program = "/bin/bash -l -c 'bundle exec sidekiqctl stop" as uid jim and 
gid jim with timeout 120 seconds
   if cpu usage > 25% for 18 cycles then restart
   if mem > 1500.0 MB for 18 cycles then restart

check file sidekiq_control with path /tmp/do_not_start_sidekiq.txt
    if does not exist then exec "/usr/bin/monit start sidekiq_1" else exec 
"/usr/bin/monit stop sidekiq_1"
--8<--

Regards,
Martin



On 23 Jul 2014, at 13:59, Niels Kristian Schjødt <address@hidden> wrote:

> I have a monit script that does something like this:
> 
> check process sidekiq_1 with pidfile /tmp/pids/sidekiq_1.pid
>  start program = "/bin/bash -l -c 'bundle exec sidekiqctl start" as uid jim 
> and gid jim with timeout 250 seconds
>  stop program = "/bin/bash -l -c 'bundle exec sidekiqctl stop" as uid jim and 
> gid jim with timeout 120 seconds
>  if cpu usage > 25% for 18 cycles then restart
>  if mem > 1500.0 MB for 18 cycles then restart
> 
> This is great, however I need to have the check made conditional based on the 
> existence of a trigger file like so: 
>       
>       Only execute the check (start the process), if the file 
> /tmp/do_not_start_sidekiq.txt is NOT present.
> 
> In this way i could do a "touch /tmp/do_not_start_sidekiq.txt” if I wanted to 
> shut down the processes and not have monit starting them again, before I did 
> a “rm /tmp/do_not_start_sidekiq.txt”
> 
> How would I do that in this monit?
> --
> To unsubscribe:
> https://lists.nongnu.org/mailman/listinfo/monit-general




reply via email to

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