|
|
cf07b3 |
From d2b7ff7208a7ad65cc8298eef4c4d32549c31d7b Mon Sep 17 00:00:00 2001
|
|
|
cf07b3 |
From: David Vossel <dvossel@redhat.com>
|
|
|
cf07b3 |
Date: Tue, 10 Sep 2013 21:16:40 -0500
|
|
|
cf07b3 |
Subject: [PATCH] Low: apache: Allow basic server request monitoring without
|
|
|
cf07b3 |
requiring server-status to be enabled
|
|
|
cf07b3 |
|
|
|
cf07b3 |
By default, the apache agent attempts to detect the location
|
|
|
cf07b3 |
of the server-status url and retrieve the contents of that URL.
|
|
|
cf07b3 |
If no regex is set, all this agent does is verify some sort
|
|
|
cf07b3 |
of html file exists at the server-status url. Essentially in
|
|
|
cf07b3 |
the default use-case, the agent is just verifying that the agent
|
|
|
cf07b3 |
can successfully request something from the webserver.
|
|
|
cf07b3 |
|
|
|
cf07b3 |
Requiring the user to enable the server-status feature
|
|
|
cf07b3 |
just to verify a request/response from the server shouldn't be
|
|
|
cf07b3 |
necessary. This patch allows the agent to fall back to
|
|
|
cf07b3 |
doing a basic http header request of the website's index
|
|
|
cf07b3 |
if the server-status check fails during a monitor... This will
|
|
|
cf07b3 |
only occur in the very basic use-case where a user has
|
|
|
cf07b3 |
not defined any statusurls, regex patterns, or custom test cases.
|
|
|
cf07b3 |
---
|
|
|
cf07b3 |
heartbeat/apache | 54 ++++++++++++++++++++++++++++++++++++++++++++++-----
|
|
|
cf07b3 |
heartbeat/http-mon.sh | 9 +++++++++
|
|
|
cf07b3 |
2 files changed, 58 insertions(+), 5 deletions(-)
|
|
|
cf07b3 |
|
|
|
cf07b3 |
diff --git a/heartbeat/apache b/heartbeat/apache
|
|
|
cf07b3 |
index 1369804..fac2a53 100755
|
|
|
cf07b3 |
--- a/heartbeat/apache
|
|
|
cf07b3 |
+++ b/heartbeat/apache
|
|
|
cf07b3 |
@@ -308,16 +308,60 @@ apache_monitor_10() {
|
|
|
cf07b3 |
return $OCF_ERR_GENERIC
|
|
|
cf07b3 |
fi
|
|
|
cf07b3 |
}
|
|
|
cf07b3 |
+
|
|
|
cf07b3 |
+# If the user has not provided any basic monitoring
|
|
|
cf07b3 |
+# information, allow the agent to verify the server is
|
|
|
cf07b3 |
+# healthy and capable of processing requests by requesting
|
|
|
cf07b3 |
+# the http header of website's index
|
|
|
cf07b3 |
+attempt_index_monitor_request() {
|
|
|
cf07b3 |
+ local indexpage=""
|
|
|
cf07b3 |
+
|
|
|
cf07b3 |
+ if [ -n "$OCF_RESKEY_client" ]; then
|
|
|
cf07b3 |
+ if [ "$OCF_RESKEY_client" != "curl" ]; then
|
|
|
cf07b3 |
+ return 1;
|
|
|
cf07b3 |
+ fi
|
|
|
cf07b3 |
+ fi
|
|
|
cf07b3 |
+ if [ -n "$OCF_RESKEY_testregex" ]; then
|
|
|
cf07b3 |
+ return 1;
|
|
|
cf07b3 |
+ fi
|
|
|
cf07b3 |
+ if [ -n "$OCF_RESKEY_testregex10" ]; then
|
|
|
cf07b3 |
+ return 1;
|
|
|
cf07b3 |
+ fi
|
|
|
cf07b3 |
+ if [ -n "$OCF_RESKEY_testurl" ]; then
|
|
|
cf07b3 |
+ return 1;
|
|
|
cf07b3 |
+ fi
|
|
|
cf07b3 |
+ if [ -n "$OCF_RESKEY_statusurl" ]; then
|
|
|
cf07b3 |
+ return 1;
|
|
|
cf07b3 |
+ fi
|
|
|
cf07b3 |
+ if [ -n "$OCF_RESKEY_testconffile" ]; then
|
|
|
cf07b3 |
+ return 1;
|
|
|
cf07b3 |
+ fi
|
|
|
cf07b3 |
+
|
|
|
cf07b3 |
+ indexpage=$(buildlocalurl)
|
|
|
cf07b3 |
+
|
|
|
cf07b3 |
+ request_url_header $indexpage > /dev/null 2>&1
|
|
|
cf07b3 |
+ if [ $? -ne 0 ]; then
|
|
|
cf07b3 |
+ return $OCF_ERR_GENERIC
|
|
|
cf07b3 |
+ fi
|
|
|
cf07b3 |
+ ocf_log info "Successfully retrieved http header at $indexpage"
|
|
|
cf07b3 |
+ return 0
|
|
|
cf07b3 |
+}
|
|
|
cf07b3 |
+
|
|
|
cf07b3 |
apache_monitor_basic() {
|
|
|
cf07b3 |
if ${ourhttpclient}_func "$STATUSURL" | grep -Ei "$TESTREGEX" > /dev/null
|
|
|
cf07b3 |
then
|
|
|
cf07b3 |
return $OCF_SUCCESS
|
|
|
cf07b3 |
- else
|
|
|
cf07b3 |
- if ! ocf_is_probe; then
|
|
|
cf07b3 |
- ocf_log err "Failed to access httpd status page."
|
|
|
cf07b3 |
- fi
|
|
|
cf07b3 |
- return $OCF_ERR_GENERIC
|
|
|
cf07b3 |
fi
|
|
|
cf07b3 |
+
|
|
|
cf07b3 |
+ attempt_index_monitor_request
|
|
|
cf07b3 |
+ if [ $? -eq 0 ]; then
|
|
|
cf07b3 |
+ return $OCF_SUCCESS
|
|
|
cf07b3 |
+ fi
|
|
|
cf07b3 |
+
|
|
|
cf07b3 |
+ if ! ocf_is_probe; then
|
|
|
cf07b3 |
+ ocf_log err "Failed to access httpd status page."
|
|
|
cf07b3 |
+ fi
|
|
|
cf07b3 |
+ return $OCF_ERR_GENERIC
|
|
|
cf07b3 |
}
|
|
|
cf07b3 |
apache_monitor() {
|
|
|
cf07b3 |
silent_status
|
|
|
cf07b3 |
diff --git a/heartbeat/http-mon.sh b/heartbeat/http-mon.sh
|
|
|
cf07b3 |
index d7b6182..fac19ef 100644
|
|
|
cf07b3 |
--- a/heartbeat/http-mon.sh
|
|
|
cf07b3 |
+++ b/heartbeat/http-mon.sh
|
|
|
cf07b3 |
@@ -24,6 +24,15 @@ fi
|
|
|
cf07b3 |
WGETOPTS="-O- -q -L --no-proxy --bind-address=$bind_address"
|
|
|
cf07b3 |
CURLOPTS="-o - -Ss -L --interface lo $curl_ipv6_opts"
|
|
|
cf07b3 |
|
|
|
cf07b3 |
+request_url_header() {
|
|
|
cf07b3 |
+ which curl >/dev/null 2>&1
|
|
|
cf07b3 |
+ if [ $? -ne 0 ]; then
|
|
|
cf07b3 |
+ return 1
|
|
|
cf07b3 |
+ fi
|
|
|
cf07b3 |
+
|
|
|
cf07b3 |
+ curl -IL --connect-timeout 5 --interface lo $curl_ipv6_opts "$1"
|
|
|
cf07b3 |
+}
|
|
|
cf07b3 |
+
|
|
|
cf07b3 |
#
|
|
|
cf07b3 |
# run the http client
|
|
|
cf07b3 |
#
|
|
|
cf07b3 |
--
|
|
|
cf07b3 |
1.8.1
|
|
|
cf07b3 |
|