From: Jim Jagielski Date: Tue, 2 Feb 2016 17:23:43 +0000 (+0000) Subject: Tie bal-man to hcheck for dynamic adjustments... right now, X-Git-Tag: 2.5.0-alpha~2220 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ee6d08cab15361f841d1c6c48490a7f06f0a5e24;p=thirdparty%2Fapache%2Fhttpd.git Tie bal-man to hcheck for dynamic adjustments... right now, actually editing not implemented yet. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1728161 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/proxy/mod_proxy.h b/modules/proxy/mod_proxy.h index ea8eeea6b73..f1d617e4613 100644 --- a/modules/proxy/mod_proxy.h +++ b/modules/proxy/mod_proxy.h @@ -562,8 +562,9 @@ struct proxy_balancer_method { #define PROXY_DECLARE_DATA __declspec(dllimport) #endif +/* Following 3 from health check */ APR_DECLARE_OPTIONAL_FN(void, hc_show_exprs, (request_rec *)); - +APR_DECLARE_OPTIONAL_FN(void, hc_select_exprs, (request_rec *, const char *)); APR_DECLARE_OPTIONAL_FN(const char *, set_worker_hc_param, (apr_pool_t *, server_rec *, proxy_worker *, const char *, const char *, void *)); diff --git a/modules/proxy/mod_proxy_balancer.c b/modules/proxy/mod_proxy_balancer.c index 143ba19173a..c7f16b62b62 100644 --- a/modules/proxy/mod_proxy_balancer.c +++ b/modules/proxy/mod_proxy_balancer.c @@ -34,6 +34,7 @@ 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; +static APR_OPTIONAL_FN_TYPE(hc_select_exprs) *hc_select_exprs_f = NULL; /* @@ -53,6 +54,7 @@ static int balancer_pre_config(apr_pool_t *pconf, apr_pool_t *plog, } set_worker_hc_param_f = APR_RETRIEVE_OPTIONAL_FN(set_worker_hc_param); hc_show_exprs_f = APR_RETRIEVE_OPTIONAL_FN(hc_show_exprs); + hc_select_exprs_f = APR_RETRIEVE_OPTIONAL_FN(hc_select_exprs); return OK; } @@ -1601,7 +1603,7 @@ static int balancer_handler(request_rec *r) "Draining Mode" "Disabled" "Hot Standby", r); - if (set_worker_hc_param_f) { + if (hc_show_exprs_f) { ap_rputs("HC Fail", r); } ap_rputs("Stopped\n", r); @@ -1609,12 +1611,34 @@ static int balancer_handler(request_rec *r) create_radio("w_status_N", (PROXY_WORKER_IS(wsel, PROXY_WORKER_DRAIN)), r); create_radio("w_status_D", (PROXY_WORKER_IS(wsel, PROXY_WORKER_DISABLED)), r); create_radio("w_status_H", (PROXY_WORKER_IS(wsel, PROXY_WORKER_HOT_STANDBY)), r); - if (set_worker_hc_param_f) { + if (hc_show_exprs_f) { create_radio("w_status_C", (PROXY_WORKER_IS(wsel, PROXY_WORKER_HC_FAIL)), r); } create_radio("w_status_S", (PROXY_WORKER_IS(wsel, PROXY_WORKER_STOPPED)), r); - ap_rputs("\n", r); - ap_rputs("\n", r); + ap_rputs("\n", r); + if (hc_select_exprs_f) { + proxy_hcmethods_t *method = proxy_hcmethods; + ap_rputs("\n\n", r); + ap_rputs("\n", r); + ap_rputs("\n", r); + ap_rprintf(r, "\n", (int)apr_time_sec(wsel->s->interval)); + ap_rprintf(r, "\n", wsel->s->fails); + ap_rprintf(r, "\n", wsel->s->passes); + ap_rprintf(r, "\n", wsel->s->hcuri); + ap_rputs("
Health Check paramValue
Method\n
Expr\n
Interval (secs)%d
Fails trigger%d
Passes trigger%d
HC uri%s
\n\n", r); + } + ap_rputs("\n", r); ap_rvputs(r, "\n\n", NULL); ap_rvputs(r, "" - "Health check cond. expressions:\n" + "Health check cond. expressions:\n" "Expr nameExpression\n", r); hdr = apr_table_elts(ctx->conditions); @@ -1028,6 +1028,28 @@ static void hc_show_exprs(request_rec *r) ap_rputs("
\n", r); } +static void hc_select_exprs(request_rec *r, const char *expr) +{ + 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; + + hdr = apr_table_elts(ctx->conditions); + elts = (const apr_table_entry_t *) hdr->elts; + for (i = 0; i < hdr->nelts; ++i) { + if (!elts[i].key) { + continue; + } + ap_rprintf(r, "\n", elts[i].key, + (!ap_casecmpstr(elts[i].key, expr)) ? "selected" : "", + elts[i].key); + } +} + static const char *hc_get_body(request_rec *r) { apr_off_t length; @@ -1115,6 +1137,7 @@ static void hc_register_hooks(apr_pool_t *p) static const char *const aszSucc[] = { "mod_watchdog.c", NULL}; APR_REGISTER_OPTIONAL_FN(set_worker_hc_param); APR_REGISTER_OPTIONAL_FN(hc_show_exprs); + APR_REGISTER_OPTIONAL_FN(hc_select_exprs); ap_hook_post_config(hc_post_config, aszPre, aszSucc, APR_HOOK_LAST); ap_hook_expr_lookup(hc_expr_lookup, NULL, NULL, APR_HOOK_MIDDLE); }