monit-general
[Top][All Lists]
Advanced

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

Re: Q: Arbitrary program status for process check?


From: Steven Christensen
Subject: Re: Q: Arbitrary program status for process check?
Date: Tue, 9 Oct 2018 14:05:15 -0400

Noel,

I see what you mean.

But if check_xyzzy fails, how can I cause xyzzy to be restarted? I don't know of any way to have one check cause another check to be restarted.

I was thinking more, and this may not be solvable with separate check statements.
I may have to combine both the checking of the process and checking of the actual functioning of the feature in a single unified script, like this:

=====================================
check program xyzzy with path "/root/check_xyzzy.sh"
      start program "/root/start_xyzzy.sh"
      stop program /usr/bin/pkill -f "xyzzy"
      if status != 0 then restart
=====================================

where check_xyzzy.sh checks 2 things:
1) ps -ef | fgrep "xyzzy"     -- to make sure the process exists
2) check the function that xyzzy provides, to make sure the function is working

It would return a bad status if either of these fails.

-- Steven


On Tue, Oct 9, 2018 at 11:22 AM Noel <address@hidden> wrote:
You have it backwards.  check_xyzzy depends on xyzzy.

First run the process, then run the script to see if the process is working.


  -- Noel Jones

On 10/8/2018 6:08 PM, Steven Christensen wrote:
Hi Viktor,

Thank you for your examples. You have a very complex monit configuration, and I can learn a lot.

However, I tried the "depends" implementation, but it did not work when trying to start the service.

If my "xyzzy" service depends on "check_xyzzy" then it will not be able to start, because before xyzzy is able to start. monit wants check_xyzzy to work, but check_xyzzy doesn't succeed, because xyzzy isn't running. It is a "chicken and egg" problem.

-- Steven



On Sat, Oct 6, 2018 at 2:03 AM SZÉPE Viktor <address@hidden> wrote:
Idézem/Quoting Steven Christensen <address@hidden>:

> Hello,
>
> Long time monit user, and I really love it.
>
> I have the following (equivalent) process monitor entry:
>
> =====================================
> check process xyzzy matching "xyzzy"
>       start program "/root/start_xyzzy.sh"
>       stop program /usr/bin/pkill -f "xyzzy"
> =====================================
>
> But sometimes the process can exist but it isn't doing what it needs to do.
> I have another script which checks if xyzzy is actually working, and
> returns a status depending on the results of the check.
>
> So I'd like something that looks like this (note last line):
> =====================================
> check process xyzzy matching "xyzzy"
>       start program "/root/start_xyzzy.sh"
>       stop program /usr/bin/pkill -f "xyzzy"
>       if program "/root/check_xyzzy.sh" status != 0 then restart
> =====================================
>
> It's the last line I don't know how to achieve. Are there any suggestions?
>
> Thanks - Steven

Hello Steven!

I use tiny script with "depends on"
https://github.com/szepeviktor/debian-server-tools/blob/master/monitoring/monit/services/fail2ban_script
to check on services
https://github.com/szepeviktor/debian-server-tools/blob/master/monitoring/monit/services/fail2ban#L11


SZÉPE Viktor, honlap üzemeltetés / Running your application
https://github.com/szepeviktor/debian-server-tools/blob/master/CV.md
--
ügyelet/hotline: +36-20-4242498  address@hidden  skype: szepe.viktor
Budapest, III. kerület






--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general


--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general

reply via email to

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