From: Jim Jagielski Date: Sun, 19 Apr 2015 18:05:15 +0000 (+0000) Subject: Merge r1671397, r1672466, r1672564 from trunk: X-Git-Tag: 2.4.13~187 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fd41c4978eecede136fd2e254e04318de8e1d88d;p=apache Merge r1671397, r1672466, r1672564 from trunk: Add output for "?auto" version of server-status to proxy status, mod_ssl session cache info, mod_cache_socache and the status hook of the individual socache implementations. Followon to r1671397 for proxy server-status in auto mode: - don't show HTML legend - Show correct worker name More followon to r1671397 for proxy server-status in auto mode: - remove remaining HTML markup Submitted by: rjung Reviewed/backported by: jim git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1674660 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/STATUS b/STATUS index b8379e5606..716790f6f5 100644 --- a/STATUS +++ b/STATUS @@ -105,16 +105,6 @@ RELEASE SHOWSTOPPERS: PATCHES ACCEPTED TO BACKPORT FROM TRUNK: [ start all new proposals below, under PATCHES PROPOSED. ] - *) mod_ssl, mod_proxy, mod_cache_socache, mod_socache_*: Add plain text - output to status hook (server-status) when called with "?auto" - (machine readable form). - trunk patch: http://svn.apache.org/r1671397 - http://svn.apache.org/r1672466 - http://svn.apache.org/r1672564 - 2.4.x patch: http://people.apache.org/~rjung/patches/enhance-socache-status-auto.patch - (same as trunk but combined into one) - +1: rjung, covener, jim - *) mod_proxy_wstunnel: Bypass the handler while the connection is not upgraded to WebSocket, so that other modules can possibly take over the leading HTTP requests. diff --git a/modules/cache/mod_cache_socache.c b/modules/cache/mod_cache_socache.c index 6bd9466bd1..c5b49ab998 100644 --- a/modules/cache/mod_cache_socache.c +++ b/modules/cache/mod_cache_socache.c @@ -1387,13 +1387,18 @@ static int socache_status_hook(request_rec *r, int flags) return DECLINED; } - ap_rputs("
\n" - "\n" - "\n" - "\n
\n" - "" - "mod_cache_socache Status:\n" - "
\n", r); + if (!(flags & AP_STATUS_SHORT)) { + ap_rputs("
\n" + "\n" + "\n" + "\n
\n" + "" + "mod_cache_socache Status:\n" + "
\n", r); + } + else { + ap_rputs("ModCacheSocacheStatus\n", r); + } if (socache_mutex) { status = apr_global_mutex_lock(socache_mutex); @@ -1404,7 +1409,12 @@ static int socache_status_hook(request_rec *r, int flags) } if (status != APR_SUCCESS) { - ap_rputs("No cache status data available\n", r); + if (!(flags & AP_STATUS_SHORT)) { + ap_rputs("No cache status data available\n", r); + } + else { + ap_rputs("NotAvailable\n", r); + } } else { conf->provider->socache_provider->status(conf->provider->socache_instance, r, flags); @@ -1418,7 +1428,9 @@ static int socache_status_hook(request_rec *r, int flags) } } - ap_rputs("
\n", r); + if (!(flags & AP_STATUS_SHORT)) { + ap_rputs("
\n", r); + } return OK; } diff --git a/modules/cache/mod_socache_dbm.c b/modules/cache/mod_socache_dbm.c index 0d7c302baf..1ffc600771 100644 --- a/modules/cache/mod_socache_dbm.c +++ b/modules/cache/mod_socache_dbm.c @@ -20,6 +20,7 @@ #include "http_protocol.h" #include "http_config.h" #include "mpm_common.h" +#include "mod_status.h" #include "apr.h" #include "apr_strings.h" @@ -497,9 +498,18 @@ static void socache_dbm_status(ap_socache_instance_t *ctx, request_rec *r, avg = (int)(size / (long)elts); else avg = 0; - ap_rprintf(r, "cache type: DBM, maximum size: unlimited
"); - ap_rprintf(r, "current entries: %d, current size: %ld bytes
", elts, size); - ap_rprintf(r, "average entry size: %d bytes
", avg); + if (!(flags & AP_STATUS_SHORT)) { + ap_rprintf(r, "cache type: DBM, maximum size: unlimited
"); + ap_rprintf(r, "current entries: %d, current size: %ld bytes
", elts, size); + ap_rprintf(r, "average entry size: %d bytes
", avg); + } + else { + ap_rputs("CacheType: DBM\n", r); + ap_rputs("CacheMaximumSize: unlimited\n", r); + ap_rprintf(r, "CacheCurrentEntries: %d\n", elts); + ap_rprintf(r, "CacheCurrentSize: %ld\n", size); + ap_rprintf(r, "CacheAvgEntrySize: %d\n", avg); + } return; } diff --git a/modules/cache/mod_socache_dc.c b/modules/cache/mod_socache_dc.c index 7d09408d6e..c1d4ab841e 100644 --- a/modules/cache/mod_socache_dc.c +++ b/modules/cache/mod_socache_dc.c @@ -19,6 +19,7 @@ #include "http_request.h" #include "http_config.h" #include "http_protocol.h" +#include "mod_status.h" #include "apr_strings.h" #include "apr_time.h" @@ -151,8 +152,14 @@ static void socache_dc_status(ap_socache_instance_t *ctx, request_rec *r, int fl { ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(00747) "distributed scache 'socache_dc_status'"); - ap_rprintf(r, "cache type: DC (Distributed Cache), " - " target: %s
", ctx->target); + if (!(flags & AP_STATUS_SHORT)) { + ap_rprintf(r, "cache type: DC (Distributed Cache), " + " target: %s
", ctx->target); + } + else { + ap_rputs("CacheType: DC\n", r); + ap_rvputs(r, "CacheTarget: ", ctx->target, "\n", NULL); + } } static apr_status_t socache_dc_iterate(ap_socache_instance_t *instance, diff --git a/modules/cache/mod_socache_shmcb.c b/modules/cache/mod_socache_shmcb.c index 4e8937750c..2731b81345 100644 --- a/modules/cache/mod_socache_shmcb.c +++ b/modules/cache/mod_socache_shmcb.c @@ -19,6 +19,7 @@ #include "http_request.h" #include "http_protocol.h" #include "http_config.h" +#include "mod_status.h" #include "apr.h" #include "apr_strings.h" @@ -606,40 +607,69 @@ static void socache_shmcb_status(ap_socache_instance_t *ctx, header->subcache_num); cache_pct = (100 * cache_total) / (header->subcache_data_size * header->subcache_num); - /* Generate HTML */ - ap_rprintf(r, "cache type: SHMCB, shared memory: %" APR_SIZE_T_FMT " " - "bytes, current entries: %d
", - ctx->shm_size, total); - ap_rprintf(r, "subcaches: %d, indexes per subcache: %d
", - header->subcache_num, header->index_num); - if (non_empty_subcaches) { - apr_time_t average_expiry = (apr_time_t)(expiry_total / (double)non_empty_subcaches); - ap_rprintf(r, "time left on oldest entries' objects: "); - if (now < average_expiry) - ap_rprintf(r, "avg: %d seconds, (range: %d...%d)
", - (int)apr_time_sec(average_expiry - now), - (int)apr_time_sec(min_expiry - now), - (int)apr_time_sec(max_expiry - now)); - else - ap_rprintf(r, "expiry_threshold: Calculation error!
"); + /* Generate Output */ + if (!(flags & AP_STATUS_SHORT)) { + ap_rprintf(r, "cache type: SHMCB, shared memory: %" APR_SIZE_T_FMT " " + "bytes, current entries: %d
", + ctx->shm_size, total); + ap_rprintf(r, "subcaches: %d, indexes per subcache: %d
", + header->subcache_num, header->index_num); + if (non_empty_subcaches) { + apr_time_t average_expiry = (apr_time_t)(expiry_total / (double)non_empty_subcaches); + ap_rprintf(r, "time left on oldest entries' objects: "); + if (now < average_expiry) + ap_rprintf(r, "avg: %d seconds, (range: %d...%d)
", + (int)apr_time_sec(average_expiry - now), + (int)apr_time_sec(min_expiry - now), + (int)apr_time_sec(max_expiry - now)); + else + ap_rprintf(r, "expiry_threshold: Calculation error!
"); + } + + ap_rprintf(r, "index usage: %d%%, cache usage: %d%%
", + index_pct, cache_pct); + ap_rprintf(r, "total entries stored since starting: %lu
", + header->stat_stores); + ap_rprintf(r, "total entries replaced since starting: %lu
", + header->stat_replaced); + ap_rprintf(r, "total entries expired since starting: %lu
", + header->stat_expiries); + ap_rprintf(r, "total (pre-expiry) entries scrolled out of the cache: " + "%lu
", header->stat_scrolled); + ap_rprintf(r, "total retrieves since starting: %lu hit, " + "%lu miss
", header->stat_retrieves_hit, + header->stat_retrieves_miss); + ap_rprintf(r, "total removes since starting: %lu hit, " + "%lu miss
", header->stat_removes_hit, + header->stat_removes_miss); } + else { + ap_rputs("CacheType: SHMCB\n", r); + ap_rprintf(r, "CacheSharedMemory: %" APR_SIZE_T_FMT "\n", + ctx->shm_size); + ap_rprintf(r, "CacheCurrentEntries: %d\n", total); + ap_rprintf(r, "CacheSubcaches: %d\n", header->subcache_num); + ap_rprintf(r, "CacheIndexesPerSubcaches: %d\n", header->index_num); + if (non_empty_subcaches) { + apr_time_t average_expiry = (apr_time_t)(expiry_total / (double)non_empty_subcaches); + if (now < average_expiry) { + ap_rprintf(r, "CacheTimeLeftOldestAvg: %d\n", (int)apr_time_sec(average_expiry - now)); + ap_rprintf(r, "CacheTimeLeftOldestMin: %d\n", (int)apr_time_sec(min_expiry - now)); + ap_rprintf(r, "CacheTimeLeftOldestMax: %d\n", (int)apr_time_sec(max_expiry - now)); + } + } - ap_rprintf(r, "index usage: %d%%, cache usage: %d%%
", - index_pct, cache_pct); - ap_rprintf(r, "total entries stored since starting: %lu
", - header->stat_stores); - ap_rprintf(r, "total entries replaced since starting: %lu
", - header->stat_replaced); - ap_rprintf(r, "total entries expired since starting: %lu
", - header->stat_expiries); - ap_rprintf(r, "total (pre-expiry) entries scrolled out of the cache: " - "%lu
", header->stat_scrolled); - ap_rprintf(r, "total retrieves since starting: %lu hit, " - "%lu miss
", header->stat_retrieves_hit, - header->stat_retrieves_miss); - ap_rprintf(r, "total removes since starting: %lu hit, " - "%lu miss
", header->stat_removes_hit, - header->stat_removes_miss); + ap_rprintf(r, "CacheIndexUsage: %d%%\n", index_pct); + ap_rprintf(r, "CacheUsage: %d%%\n", cache_pct); + ap_rprintf(r, "CacheStoreCount: %lu\n", header->stat_stores); + ap_rprintf(r, "CacheReplaceCount: %lu\n", header->stat_replaced); + ap_rprintf(r, "CacheExpireCount: %lu\n", header->stat_expiries); + ap_rprintf(r, "CacheDiscardCount: %lu\n", header->stat_scrolled); + ap_rprintf(r, "CacheRetrieveHitCount: %lu\n", header->stat_retrieves_hit); + ap_rprintf(r, "CacheRetrieveMissCount: %lu\n", header->stat_retrieves_miss); + ap_rprintf(r, "CacheRemoveHitCount: %lu\n", header->stat_removes_hit); + ap_rprintf(r, "CacheRemoveMissCount: %lu\n", header->stat_removes_miss); + } ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(00841) "leaving shmcb_status"); } diff --git a/modules/proxy/mod_proxy.c b/modules/proxy/mod_proxy.c index 885a2c9eed..6fe8517606 100644 --- a/modules/proxy/mod_proxy.c +++ b/modules/proxy/mod_proxy.c @@ -2538,77 +2538,103 @@ static int proxy_status_hook(request_rec *r, int flags) proxy_balancer *balancer = NULL; proxy_worker **worker = NULL; - if ((flags & AP_STATUS_SHORT) || conf->balancers->nelts == 0 || + if (conf->balancers->nelts == 0 || conf->proxy_status == status_off) return OK; balancer = (proxy_balancer *)conf->balancers->elts; for (i = 0; i < conf->balancers->nelts; i++) { - ap_rputs("
\n

Proxy LoadBalancer Status for ", r); - ap_rvputs(r, balancer->s->name, "

\n\n", NULL); - ap_rputs("\n\n" - "" - "\n", r); - if (*balancer->s->sticky) { - if (strcmp(balancer->s->sticky, balancer->s->sticky_path)) { - ap_rvputs(r, "
SSesTimeoutMethod
", balancer->s->sticky, " | ", - balancer->s->sticky_path, NULL); + if (!(flags & AP_STATUS_SHORT)) { + ap_rputs("
\n

Proxy LoadBalancer Status for ", r); + ap_rvputs(r, balancer->s->name, "

\n\n", NULL); + ap_rputs("\n\n" + "" + "\n", r); + if (*balancer->s->sticky) { + if (strcmp(balancer->s->sticky, balancer->s->sticky_path)) { + ap_rvputs(r, "", + apr_time_sec(balancer->s->timeout)); + ap_rprintf(r, "\n", + balancer->lbmethod->name); + ap_rputs("
SSesTimeoutMethod
", balancer->s->sticky, " | ", + balancer->s->sticky_path, NULL); + } + else { + ap_rvputs(r, "", balancer->s->sticky, NULL); + } } else { - ap_rvputs(r, "", balancer->s->sticky, NULL); + ap_rputs(" - ", r); } + ap_rprintf(r, "%" APR_TIME_T_FMT "%s
\n", r); + ap_rputs("\n\n" + "" + "" + "" + "\n", r); } else { - ap_rputs("", - apr_time_sec(balancer->s->timeout)); - ap_rprintf(r, "\n", - balancer->lbmethod->name); - ap_rputs("
SchHostStatRouteRedirFSetAccWrRd
- ", r); - } - ap_rprintf(r, "%" APR_TIME_T_FMT "%s
\n", r); - ap_rputs("\n\n" - "" - "" - "" - "\n", r); + ap_rprintf(r, "ProxyBalancer[%d]Name: %s\n", i, balancer->s->name); + } worker = (proxy_worker **)balancer->workers->elts; for (n = 0; n < balancer->workers->nelts; n++) { char fbuf[50]; - ap_rvputs(r, "\n", NULL); - ap_rvputs(r, "", (*worker)->s->lbfactor); - ap_rprintf(r, "", (*worker)->s->lbset); - ap_rprintf(r, "\n", r); - - /* TODO: Add the rest of dynamic worker data */ - ap_rputs("\n", r); + if (!(flags & AP_STATUS_SHORT)) { + ap_rvputs(r, "\n", NULL); + ap_rvputs(r, "", (*worker)->s->lbfactor); + ap_rprintf(r, "", (*worker)->s->lbset); + ap_rprintf(r, "\n", r); + + /* TODO: Add the rest of dynamic worker data */ + ap_rputs("\n", r); + } + else { + ap_rprintf(r, "ProxyBalancer[%d]Worker[%d]Name: %s\n", + i, n, (*worker)->s->name); + ap_rprintf(r, "ProxyBalancer[%d]Worker[%d]Status: %s\n", + i, n, ap_proxy_parse_wstatus(r->pool, *worker)); + ap_rprintf(r, "ProxyBalancer[%d]Worker[%d]Elected: %" + APR_SIZE_T_FMT "\n", + i, n, (*worker)->s->elected); + ap_rprintf(r, "ProxyBalancer[%d]Worker[%d]Sent: %s\n", + i, n, apr_strfsize((*worker)->s->transferred, fbuf)); + ap_rprintf(r, "ProxyBalancer[%d]Worker[%d]Rcvd: %s\n", + i, n, apr_strfsize((*worker)->s->read, fbuf)); + /* TODO: Add the rest of dynamic worker data */ + } ++worker; } - ap_rputs("
SchHostStatRouteRedirFSetAccWrRd
", (*worker)->s->scheme, "", (*worker)->s->hostname, "", NULL); - ap_rvputs(r, ap_proxy_parse_wstatus(r->pool, *worker), NULL); - ap_rvputs(r, "", (*worker)->s->route, NULL); - ap_rvputs(r, "", (*worker)->s->redirect, NULL); - ap_rprintf(r, "%d%d%" APR_SIZE_T_FMT "", (*worker)->s->elected); - ap_rputs(apr_strfsize((*worker)->s->transferred, fbuf), r); - ap_rputs("", r); - ap_rputs(apr_strfsize((*worker)->s->read, fbuf), r); - ap_rputs("
", (*worker)->s->scheme, "", (*worker)->s->hostname, "", NULL); + ap_rvputs(r, ap_proxy_parse_wstatus(r->pool, *worker), NULL); + ap_rvputs(r, "", (*worker)->s->route, NULL); + ap_rvputs(r, "", (*worker)->s->redirect, NULL); + ap_rprintf(r, "%d%d%" APR_SIZE_T_FMT "", + (*worker)->s->elected); + ap_rputs(apr_strfsize((*worker)->s->transferred, fbuf), r); + ap_rputs("", r); + ap_rputs(apr_strfsize((*worker)->s->read, fbuf), r); + ap_rputs("
\n", r); + if (!(flags & AP_STATUS_SHORT)) { + ap_rputs("
\n", r); + } ++balancer; } - ap_rputs("
\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "
SSesSticky session name
TimeoutBalancer Timeout
SchConnection scheme
HostBackend Hostname
StatWorker status
RouteSession Route
RedirSession Route Redirection
FLoad Balancer Factor
AccNumber of uses
WrNumber of bytes transferred
RdNumber of bytes read
", r); + if (!(flags & AP_STATUS_SHORT)) { + ap_rputs("
\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "
SSesSticky session name
TimeoutBalancer Timeout
SchConnection scheme
HostBackend Hostname
StatWorker status
RouteSession Route
RedirSession Route Redirection
FLoad Balancer Factor
AccNumber of uses
WrNumber of bytes transferred
RdNumber of bytes read
", r); + } return OK; } diff --git a/modules/ssl/ssl_scache.c b/modules/ssl/ssl_scache.c index 01f72546cd..2d365b2215 100644 --- a/modules/ssl/ssl_scache.c +++ b/modules/ssl/ssl_scache.c @@ -198,15 +198,20 @@ static int ssl_ext_status_hook(request_rec *r, int flags) { SSLModConfigRec *mc = myModConfig(r->server); - if (mc == NULL || flags & AP_STATUS_SHORT || mc->sesscache == NULL) + if (mc == NULL || mc->sesscache == NULL) return OK; - ap_rputs("
\n", r); - ap_rputs("\n", r); - ap_rputs("\n", r); - ap_rputs("\n", r); + ap_rputs("
\n", r); - ap_rputs("SSL/TLS Session Cache Status:\r", r); - ap_rputs("
\n", r); + if (!(flags & AP_STATUS_SHORT)) { + ap_rputs("
\n", r); + ap_rputs("\n", r); + ap_rputs("\n", r); + ap_rputs("\n", r); - ap_rputs("
\n", r); + ap_rputs("SSL/TLS Session Cache Status:\r", r); + ap_rputs("
\n", r); + } + else { + ap_rputs("TLSSessionCacheStatus\n", r); + } if (mc->sesscache->flags & AP_SOCACHE_FLAG_NOTMPSAFE) { ssl_mutex_on(r->server); @@ -218,8 +223,11 @@ static int ssl_ext_status_hook(request_rec *r, int flags) ssl_mutex_off(r->server); } - ap_rputs("
\n", r); + if (!(flags & AP_STATUS_SHORT)) { + ap_rputs("
\n", r); + } + return OK; }