Only one alert

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Only one alert

Paul van der Vlis
Hello,

I want to monitor several sites on the same host, both http and https,
but I want to get only one alert when there is a problem. Is that possible?

With regards,
Paul van der Vlis




--
Paul van der Vlis Linux systeembeheer Groningen
https://www.vandervlis.nl/

Reply | Threaded
Open this post in threaded view
|

Re: Only one alert

Lutz Mader
Hello,
the answer is no, I think.

> I want to monitor several sites on the same host, both http and https,
> but I want to get only one alert when there is a problem. Is that possible?

But you can use a dummy service with multiple failed host tests.

check process Server matching "sleep"
  start program "/bin/ksh -c 'sleep 31536000 &'" with timeout 120 seconds
#  stop program "" with timeout 120 seconds
  if failed host mmonit.com port 80 then alert
  if failed host google.com port 80 then alert
:
  if failed host yahoo.com port 80 then alert

This will reduce the number of alerts, but you get an alert if one of
the hosts is not reachable. But I prefere the remote host check for all
hosts and use an additional tool to handle the notification requests.

With regards,
Lutz

Reply | Threaded
Open this post in threaded view
|

Re: Only one alert

Paul van der Vlis
Hello Lutz, and others,

Op 30-08-19 om 22:01 schreef Lutz Mader:

> Hello,
> the answer is no, I think.
>
>> I want to monitor several sites on the same host, both http and https,
>> but I want to get only one alert when there is a problem. Is that possible?
>
> But you can use a dummy service with multiple failed host tests.
>
> check process Server matching "sleep"
>   start program "/bin/ksh -c 'sleep 31536000 &'" with timeout 120 seconds
> #  stop program "" with timeout 120 seconds
>   if failed host mmonit.com port 80 then alert
>   if failed host google.com port 80 then alert
> :
>   if failed host yahoo.com port 80 then alert

I must say I do not understand what you are doing here.

In your example you are using sites on different hosts. I want to
monitor more sites (virtual hosts) on the same host. But when e.g.
Apache is down, I don't want to get many alerts.

> This will reduce the number of alerts, but you get an alert if one of
> the hosts is not reachable. But I prefere the remote host check for all
> hosts and use an additional tool to handle the notification requests.

I am also executing a script.

Can you tell more about what you do to avoid getting many alerts?

With regards,
Paul



--
Paul van der Vlis Linux systeembeheer Groningen
https://www.vandervlis.nl/

Reply | Threaded
Open this post in threaded view
|

Re: Only one alert

monit-general mailing list
Since you are launching a script from monit, how about this approach?

check program webserver_vhosts with path "/usr/local/bin/checkvhosts.sh" every 4 cycles
    if status > 0 then alert


Then in the checkvhosts.sh there could be something like this:

#!/bin/bash

VHOSTS="url1 url2 url3 url4"

ERRORS=0
for VHOST in $VHOSTS; do
  /usr/lib64/nagios/plugins/check_http -H $VHOST -t 20 -f follow -u "/" -s Copyright
  [[ "$?" -ne 0 ]] && ((ERRORS++))
done

exit $ERRORS


The key to what you are needing to do requires a web client that will send the host header to your web server.  This could be wget, curl or a number of tools but it's more than a simple TCP port check.

That command above looks for the word "Copyright" in the web server output so adjust as needed.

Obviously this is using the nrpe-plugins tool check_http so install that package.


From: monit-general <monit-general-bounces+djones=[hidden email]> on behalf of Paul van der Vlis <[hidden email]>
Sent: Saturday, August 31, 2019 3:55 PM
To: [hidden email] <[hidden email]>
Subject: Re: Only one alert
 
Hello Lutz, and others,

Op 30-08-19 om 22:01 schreef Lutz Mader:
> Hello,
> the answer is no, I think.
>
>> I want to monitor several sites on the same host, both http and https,
>> but I want to get only one alert when there is a problem. Is that possible?
>
> But you can use a dummy service with multiple failed host tests.
>
> check process Server matching "sleep"
>   start program "/bin/ksh -c 'sleep 31536000 &'" with timeout 120 seconds
> #  stop program "" with timeout 120 seconds
>   if failed host mmonit.com port 80 then alert
>   if failed host google.com port 80 then alert
> :
>   if failed host yahoo.com port 80 then alert

I must say I do not understand what you are doing here.

In your example you are using sites on different hosts. I want to
monitor more sites (virtual hosts) on the same host. But when e.g.
Apache is down, I don't want to get many alerts.

> This will reduce the number of alerts, but you get an alert if one of
> the hosts is not reachable. But I prefere the remote host check for all
> hosts and use an additional tool to handle the notification requests.

I am also executing a script.

Can you tell more about what you do to avoid getting many alerts?

With regards,
Paul



--
Paul van der Vlis Linux systeembeheer Groningen
https://www.vandervlis.nl/

Reply | Threaded
Open this post in threaded view
|

Re: Only one alert

Lutz Mader
In reply to this post by Paul van der Vlis
Hello,
> I must say I do not understand what you are doing here.

I use a dummy process and add some simple host tests to check some site
addresses.

> Can you tell more about what you do to avoid getting many alerts?

My central tool avoid resending alerts/notifications for a service, but
monit reduce the number of alerts/notification send also.

I prefer the more detailed remote host service, see
https://mmonit.com/monit/documentation/monit.html#CONNECTION-TESTS

With regards,
Lutz