From: Jim Jagielski Date: Tue, 13 Dec 2016 13:57:02 +0000 (+0000) Subject: Merge r1768245, r1770828 from trunk: X-Git-Tag: 2.4.24~30 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a2b500cfaa4f31f8980b522298024888e50b5810;p=thirdparty%2Fapache%2Fhttpd.git Merge r1768245, r1770828 from trunk: heh... bring memcache up to redis :) mod_status info From Norm: NWGNUsocachmem needs to find mod_status.h Reviewed/backported by: jim git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1774016 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 316a95aa740..388c6d1abd8 100644 --- a/CHANGES +++ b/CHANGES @@ -22,6 +22,9 @@ Changes with Apache 2.4.24 MAC (SipHash) to prevent deciphering or tampering with a padding oracle attack. [Yann Ylavic, Colm MacCarthaigh] + *) mod_socache_memcache: Provide memcache stats to mod_status. + [Jim Jagielski] + *) http_filters: Fix potential looping in new check_headers() due to new pattern of ap_die() from http header filter. Explicitly clear the previous headers and body. diff --git a/STATUS b/STATUS index a3caf0b01a5..76ae9659794 100644 --- a/STATUS +++ b/STATUS @@ -119,11 +119,6 @@ RELEASE SHOWSTOPPERS: PATCHES ACCEPTED TO BACKPORT FROM TRUNK: [ start all new proposals below, under PATCHES PROPOSED. ] - *) mod_socache_memcache: Provide memcache STATs to mod_status - trunk patch: http://svn.apache.org/r1768245 - trunk patch: http://svn.apache.org/r1770828 - 2.4.x patch: trunk works - +1: jim, icing, covener PATCHES PROPOSED TO BACKPORT FROM TRUNK: [ New proposals should be added at the end of the list ] diff --git a/modules/cache/NWGNUsocachmem b/modules/cache/NWGNUsocachmem index d8d10d8a345..cfbf815ec78 100644 --- a/modules/cache/NWGNUsocachmem +++ b/modules/cache/NWGNUsocachmem @@ -26,6 +26,7 @@ XINCDIRS += \ $(APR)/include \ $(APRUTIL)/include \ $(AP_WORK)/include \ + $(STDMOD)/generators \ $(AP_WORK)/server/mpm/netware \ $(NWOS) \ $(EOLIST) diff --git a/modules/cache/mod_socache_memcache.c b/modules/cache/mod_socache_memcache.c index 86577a9f7b1..28f981377ad 100644 --- a/modules/cache/mod_socache_memcache.c +++ b/modules/cache/mod_socache_memcache.c @@ -17,6 +17,7 @@ #include "httpd.h" #include "http_config.h" +#include "http_protocol.h" #include "apr.h" #include "apu_version.h" @@ -33,6 +34,8 @@ #include "ap_mpm.h" #include "http_log.h" #include "apr_memcache.h" +#include "apr_strings.h" +#include "mod_status.h" /* The underlying apr_memcache system is thread safe.. */ #define MC_KEY_LEN 254 @@ -293,7 +296,58 @@ static apr_status_t socache_mc_remove(ap_socache_instance_t *ctx, server_rec *s, static void socache_mc_status(ap_socache_instance_t *ctx, request_rec *r, int flags) { - /* TODO: Make a mod_status handler. meh. */ + apr_memcache_t *rc = ctx->mc; + int i; + + for (i = 0; i < rc->ntotal; i++) { + apr_memcache_server_t *ms; + apr_memcache_stats_t *stats; + apr_status_t rv; + char *br = (!(flags & AP_STATUS_SHORT) ? "
" : ""); + + ms = rc->live_servers[i]; + + ap_rprintf(r, "Memcached server: %s:%d [%s]%s\n", ms->host, (int)ms->port, + (ms->status == APR_MC_SERVER_LIVE) ? "Up" : "Down", + br); + rv = apr_memcache_stats(ms, r->pool, &stats); + if (rv != APR_SUCCESS) + continue; + if (!(flags & AP_STATUS_SHORT)) { + ap_rprintf(r, "Version: %s [%u bits], PID: %u, Uptime: %u hrs
\n", + stats->version , stats->pointer_size, stats->pid, stats->uptime/3600); + ap_rprintf(r, "Clients:: Structures: %u, Total: %u, Current: %u
\n", + stats->connection_structures, stats->total_connections, stats->curr_connections); + ap_rprintf(r, "Storage:: Total Items: %u, Current Items: %u, Bytes: %lu
\n", + stats->total_items, stats->curr_items, stats->bytes); + ap_rprintf(r, "CPU:: System: %u, User: %u
\n", + (unsigned)stats->rusage_system, (unsigned)stats->rusage_user ); + ap_rprintf(r, "Cache:: Gets: %u, Sets: %u, Hits: %u, Misses: %u
\n", + stats->cmd_get, stats->cmd_set, stats->get_hits, stats->get_misses); + ap_rprintf(r, "Net:: Input bytes: %lu, Output bytes: %lu
\n", + stats->bytes_read, stats->bytes_written); + ap_rprintf(r, "Misc:: Evictions: %lu, MaxMem: %u, Threads: %u
\n", + stats->evictions, stats->limit_maxbytes, stats->threads); + ap_rputs("

\n", r); + } + else { + ap_rprintf(r, "Version: %s [%u bits], PID: %u, Uptime: %u hrs %s\n", + stats->version , stats->pointer_size, stats->pid, stats->uptime/3600, br); + ap_rprintf(r, "Clients:: Structures: %d, Total: %d, Current: %u %s\n", + stats->connection_structures, stats->total_connections, stats->curr_connections, br); + ap_rprintf(r, "Storage:: Total Items: %u, Current Items: %u, Bytes: %lu %s\n", + stats->total_items, stats->curr_items, stats->bytes, br); + ap_rprintf(r, "CPU:: System: %u, User: %u %s\n", + (unsigned)stats->rusage_system, (unsigned)stats->rusage_user , br); + ap_rprintf(r, "Cache:: Gets: %u, Sets: %u, Hits: %u, Misses: %u %s\n", + stats->cmd_get, stats->cmd_set, stats->get_hits, stats->get_misses, br); + ap_rprintf(r, "Net:: Input bytes: %lu, Output bytes: %lu %s\n", + stats->bytes_read, stats->bytes_written, br); + ap_rprintf(r, "Misc:: Evictions: %lu, MaxMem: %u, Threads: %u %s\n", + stats->evictions, stats->limit_maxbytes, stats->threads, br); + } + } + } static apr_status_t socache_mc_iterate(ap_socache_instance_t *instance,