monit-general
[Top][All Lists]
Advanced

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

Re: How to use curl to check if service is down?


From: Anthony Ettinger
Subject: Re: How to use curl to check if service is down?
Date: Mon, 27 Jun 2022 05:07:03 -0700

One thing I'm not sure about is how monit knows which systemd service to restart. I haven't specified it anywhere.

On Sun, Jun 26, 2022 at 11:15 PM Lutz Mader <lutz.mader@freenet.de> wrote:
Hello Anthony,
as long as you are sure the http status is 200, you can use this.

> This is what I have now, but I don't know if its correct:
>
> check host grazily.com with address grazily.com
>         start program = "/bin/systemctl start grazily-api"
>         stop program = "/bin/systemctl stop grazily-api"
>
>         if failed
>                 port 443 protocol http and request "/api/1" method GET
> status != 200
>         then restart

Unfortunately, in general you will get some other status codes too, but
this depends to your application.
I use an addition "... with timeout 30 seconds retry 5 then" to prevent
restart problems. And for "ssl" connections you can use "... and
certificate valid > 30 days ..." too.

if failed
   port 443 protocol http and request "/api/1" method GET
   status != 200
   with timeout 30 seconds retry 5
   then restart

See https://mmonit.com/monit/documentation/monit.html#HTTP

With regards,
Lutz



--
Anthony
408-656-2473

reply via email to

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