Hi
An interesting situation: a website is hosted at the provider. Configured on the two web services, Nginx and Apache. Apache is behind nginx. Ports 80 and 443 Nginx included on monitoring NagiosXI. But the Apache and its ports do not have the opportunity to take in monitoring Nagios, the provider does not give access to it. One of these days fell on a hosting service Apache, ports Nginx show that everything is OK, and the request to the web site gives an error "502 Bad gateway". So the question is - How can I take on monitoring Nagios Apache ports beyond the Nginx? Maybe it is possible to take in the monitoring of response "502 Bad gateway"?
Best Regards
Valery
Error 502 Bad gateway not tracked
Re: Error 502 Bad gateway not tracked
Are you saying that the nginx and apache websites are somehow linked, and you want to use the 502 status on the nginx pages as an indication that apache is down?
If so, there is a switch you can add to check_http to check for a specific HTTP code:
That will show Critical if any status other than 200 is given. Otherwise, you can search for "502 Bad gateway" in the body like so:
This is saying "I expect this string to be present (OK) to alert if it is not (Critical)". This allows you to get around the possibility that the page might display a 502 error but return a 200 HTTP code, in cases where the front-end nginx is pulling from the back-end apache.
If so, there is a switch you can add to check_http to check for a specific HTTP code:
Code: Select all
./check_http -H <hostaddress> -e 200Code: Select all
./check_http -H <hostaddress> -r "502 Bad gateway" --invert-regexFormer Nagios employee
Re: Error 502 Bad gateway not tracked
"Are you saying that the nginx and apache websites are somehow linked, and you want to use the 502 status on the nginx pages as an indication that apache is down?"
Yes exactly. Nginx used as a balancer requests.
-
On request
gives the answer
despite the fact that the site is working normally.
On request
gives the answer
although the site is working and not an error "502 Bad gateway"
-
It turns out that the first method does not work, and the second way - the answer is and must be at the same time having received an request?
Yes exactly. Nginx used as a balancer requests.
-
On request
Code: Select all
./check_http -H <hostaddress> -e 200Code: Select all
COMMAND: /usr/local/nagios/libexec/check_http -H <hostaddress> -e 200
OUTPUT: HTTP CRITICAL - Invalid HTTP response received from host: HTTP/1.1 301 Moved PermanentlyOn request
Code: Select all
./check_http -H <hostaddress> -r "502 Bad gateway" --invert-regexCode: Select all
COMMAND: /usr/local/nagios/libexec/check_http -H <hostaddress> -r "502 Bad gateway" --invert-regex
OUTPUT: HTTP OK: HTTP/1.1 301 Moved Permanently - 509 bytes in 0.010 second response time |time=0.010403s;;;0.000000 size=509B;;;0-
It turns out that the first method does not work, and the second way - the answer is and must be at the same time having received an request?
-
jdalrymple
- Skynet Drone
- Posts: 2620
- Joined: Wed Feb 11, 2015 1:56 pm
Re: Error 502 Bad gateway not tracked
Take a look at this thread. This individual had a similar problem to yours, 502 didn't exhibit for him the expected results when using check_http - but when we do it internally it works fine.
I killed the apache webserver behind the nginx reverse proxy here
Note - no fancy code, no arguments necessary.
Code: Select all
[jdalrymple@localhost libexec]$ curl http://www.somewebsite.org | head -10
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0<!DOCTYPE html>
<!--[if IE 7]>
<html class="ie ie7" lang="en-US">
<![endif]-->
<!--[if IE 8]>
<html class="ie ie8" lang="en-US">
<![endif]-->
<!--[if !(IE 7) & !(IE 8)]><!-->
<html lang="en-US">
<!--<![endif]-->
100 7854 0 7854 0 0 14997 0 --:--:-- --:--:-- --:--:-- 17261
curl: (23) Failed writing body (338 != 1455)
[jdalrymple@localhost libexec]$ ./check_http -H www.somewebsite.org
HTTP OK: HTTP/1.1 200 OK - 11795 bytes in 0.363 second response time |time=0.363233s;;;0.000000 size=11795B;;;0Code: Select all
[jdalrymple@localhost libexec]$ curl http://www.somewebsite.org | head -10
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
172 172 172 172 0 0 1774 0 --:--:-- --:--:-- --:--:-- 7478
<html>
<head><title>502 Bad Gateway</title></head>
<body bgcolor="white">
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx/1.6.2</center>
</body>
</html>
[jdalrymple@localhost libexec]$ ./check_http -H www.somewebsite.org
HTTP CRITICAL: HTTP/1.1 502 Bad Gateway - 323 bytes in 0.076 second response time |time=0.075966s;;;0.000000 size=323B;;;0Re: Error 502 Bad gateway not tracked
Ok
I read the debate on your link necessarily.
Regarding my case - it seems that the second way of working! Tonight received an SMS message about the status of the Apache "Critical".
Then he received a SMS message that everything is OK.
Thank you for the help
Topic can be closed
Best Regards
Valery
I read the debate on your link necessarily.
Regarding my case - it seems that the second way of working! Tonight received an SMS message about the status of the Apache "Critical".
Code: Select all
HTTP_Apache CRITICAL 05-14-2015 03:10:24 sms_valery notify-service-by-sms HTTP CRITICAL: HTTP/1.1 502 Bad Gateway - 323 bytes in 0.011 second response timeCode: Select all
HTTP_Apache OK 05-14-2015 03:19:19 sms_valery notify-service-by-sms HTTP OK: HTTP/1.1 301 Moved Permanently - 509 bytes in 0.104 second response timeTopic can be closed
Best Regards
Valery