]> granicus.if.org Git - apache/commitdiff
And make the list of health check conditions viewable via
authorJim Jagielski <jim@apache.org>
Tue, 19 Jan 2016 20:48:33 +0000 (20:48 +0000)
committerJim Jagielski <jim@apache.org>
Tue, 19 Jan 2016 20:48:33 +0000 (20:48 +0000)
the balancer manager :)

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1725609 13f79535-47bb-0310-9956-ffa450edef68

modules/proxy/mod_proxy.h
modules/proxy/mod_proxy_balancer.c
modules/proxy/mod_proxy_hcheck.c

index 125a8fa3f0f1e1329e2b45d93126de41760ebce4..f6312fd4594b0930c5db93010bfa606c499c27b4 100644 (file)
@@ -552,10 +552,13 @@ struct proxy_balancer_method {
 #define PROXY_DECLARE_DATA             __declspec(dllimport)
 #endif
 
+APR_DECLARE_OPTIONAL_FN(void, hc_show_exprs, (request_rec *));
+
 APR_DECLARE_OPTIONAL_FN(const char *, set_worker_hc_param,
                         (apr_pool_t *, server_rec *, proxy_worker *,
                          const char *, const char *, void *));
 
+
 APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, scheme_handler, (request_rec *r,
                           proxy_worker *worker, proxy_server_conf *conf, char *url,
                           const char *proxyhost, apr_port_t proxyport))
index f1c0a6f146de2126c8aaececf77b2ca7c142b302..e1d518f96badb990eebfa136db4c39fd0057747e 100644 (file)
@@ -33,6 +33,9 @@ static APR_OPTIONAL_FN_TYPE(set_worker_hc_param) *set_worker_hc_param_f = NULL;
 static int (*ap_proxy_retry_worker_fn)(const char *proxy_function,
         proxy_worker *worker, server_rec *s) = NULL;
 
+static APR_OPTIONAL_FN_TYPE(hc_show_exprs) *hc_show_exprs_f = NULL;
+
+
 /*
  * Register our mutex type before the config is read so we
  * can adjust the mutex settings using the Mutex directive.
@@ -49,6 +52,7 @@ static int balancer_pre_config(apr_pool_t *pconf, apr_pool_t *plog,
         return rv;
     }
     set_worker_hc_param_f = APR_RETRIEVE_OPTIONAL_FN(set_worker_hc_param);
+    hc_show_exprs_f = APR_RETRIEVE_OPTIONAL_FN(hc_show_exprs);
     return OK;
 }
 
@@ -1572,6 +1576,9 @@ static int balancer_handler(request_rec *r)
             ++balancer;
         }
         ap_rputs("<hr />\n", r);
+        if (hc_show_exprs_f) {
+            hc_show_exprs_f(r);
+        }
         if (wsel && bsel) {
             ap_rputs("<h3>Edit worker settings for ", r);
             ap_rvputs(r, (*wsel->s->uds_path?"<i>":""), ap_proxy_worker_name(r->pool, wsel), (*wsel->s->uds_path?"</i>":""), "</h3>\n", NULL);
index 67d018f526109d6f852e4a9854b029f16cba9dec..b40c3b5eb9ab48ff1fc1ba5486e19832e092de7e 100644 (file)
@@ -824,6 +824,34 @@ static int hc_post_config(apr_pool_t *p, apr_pool_t *plog,
     return OK;
 }
 
+static void hc_show_exprs(request_rec *r)
+{
+    const apr_table_entry_t *elts;
+    const apr_array_header_t *hdr;
+    int i;
+    sctx_t *ctx = (sctx_t *) ap_get_module_config(r->server->module_config,
+                                                  &proxy_hcheck_module);
+    if (apr_is_empty_table(ctx->conditions))
+        return;
+
+    ap_rputs("\n\n<table>"
+             "<tr><th colspan=\"2\">Health check cond. expressions:</th></tr>\n"
+             "<tr><th>Expr name</th><th>Expression</th></tr>\n", r);
+
+    hdr = apr_table_elts(ctx->conditions);
+    elts = (const apr_table_entry_t *) hdr->elts;
+    for (i = 0; i < hdr->nelts; ++i) {
+        hc_condition_t *cond;
+        if (!elts[i].key) {
+            continue;
+        }
+        cond = (hc_condition_t *)elts[i].val;
+        ap_rprintf(r, "<tr><td>%s</td><td>%s</td></tr>\n", elts[i].key,
+                   cond->expr);
+    }
+    ap_rputs("</table><hr/>\n", r);
+}
+
 static const command_rec command_table[] = {
     AP_INIT_RAW_ARGS("ProxyHCTemplate", set_hc_template, NULL, OR_FILEINFO,
                      "Health check template"),
@@ -837,6 +865,7 @@ static void hc_register_hooks(apr_pool_t *p)
     static const char *const aszPre[] = { "mod_proxy_balancer.c", "mod_proxy.c", NULL};
     static const char *const aszSucc[] = { "mod_watchdog.c", NULL};
     APR_REGISTER_OPTIONAL_FN(set_worker_hc_param);
+    APR_REGISTER_OPTIONAL_FN(hc_show_exprs);
     ap_hook_post_config(hc_post_config, aszPre, aszSucc, APR_HOOK_LAST);
 }