]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Add output for "?auto" version of server-status
authorRainer Jung <rjung@apache.org>
Sun, 5 Apr 2015 13:54:22 +0000 (13:54 +0000)
committerRainer Jung <rjung@apache.org>
Sun, 5 Apr 2015 13:54:22 +0000 (13:54 +0000)
to proxy status, mod_ssl session cache info,
mod_cache_socache and the status hook of the
individual socache implementations.

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

modules/cache/mod_cache_socache.c
modules/cache/mod_socache_dbm.c
modules/cache/mod_socache_dc.c
modules/cache/mod_socache_shmcb.c
modules/proxy/mod_proxy.c
modules/ssl/ssl_scache.c

index 6bd9466bd19d683832c117a4fc43381bbc18f27c..c5b49ab998f252e6d53209ed1ef676e64fea7220 100644 (file)
@@ -1387,13 +1387,18 @@ static int socache_status_hook(request_rec *r, int flags)
         return DECLINED;
     }
 
-    ap_rputs("<hr>\n"
-             "<table cellspacing=0 cellpadding=0>\n"
-             "<tr><td bgcolor=\"#000000\">\n"
-             "<b><font color=\"#ffffff\" face=\"Arial,Helvetica\">"
-             "mod_cache_socache Status:</font></b>\n"
-             "</td></tr>\n"
-             "<tr><td bgcolor=\"#ffffff\">\n", r);
+    if (!(flags & AP_STATUS_SHORT)) {
+        ap_rputs("<hr>\n"
+                 "<table cellspacing=0 cellpadding=0>\n"
+                 "<tr><td bgcolor=\"#000000\">\n"
+                 "<b><font color=\"#ffffff\" face=\"Arial,Helvetica\">"
+                 "mod_cache_socache Status:</font></b>\n"
+                 "</td></tr>\n"
+                 "<tr><td bgcolor=\"#ffffff\">\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("</td></tr>\n</table>\n", r);
+    if (!(flags & AP_STATUS_SHORT)) {
+        ap_rputs("</td></tr>\n</table>\n", r);
+    }
     return OK;
 }
 
index 984d2b7111c312a23e721651670ac51e0785669c..44ff040b4593ab087251fbc9c1884120a264672f 100644 (file)
@@ -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: <b>DBM</b>, maximum size: <b>unlimited</b><br>");
-    ap_rprintf(r, "current entries: <b>%d</b>, current size: <b>%ld</b> bytes<br>", elts, size);
-    ap_rprintf(r, "average entry size: <b>%d</b> bytes<br>", avg);
+    if (!(flags & AP_STATUS_SHORT)) {
+        ap_rprintf(r, "cache type: <b>DBM</b>, maximum size: <b>unlimited</b><br>");
+        ap_rprintf(r, "current entries: <b>%d</b>, current size: <b>%ld</b> bytes<br>", elts, size);
+        ap_rprintf(r, "average entry size: <b>%d</b> bytes<br>", 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;
 }
 
index 7d09408d6e1ea490f3786edc044c1f1194902607..c1d4ab841ecdbacc693b554c542ef8fe5e17febc 100644 (file)
@@ -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: <b>DC (Distributed Cache)</b>, "
-               " target: <b>%s</b><br>", ctx->target);
+    if (!(flags & AP_STATUS_SHORT)) {
+        ap_rprintf(r, "cache type: <b>DC (Distributed Cache)</b>, "
+                   " target: <b>%s</b><br>", 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,
index 706c2f74f69daebbb34b64f9d5313efce742b4c6..6d601b9eefbee469789c0695c671bca6af8f6717 100644 (file)
@@ -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: <b>SHMCB</b>, shared memory: <b>%" APR_SIZE_T_FMT "</b> "
-               "bytes, current entries: <b>%d</b><br>",
-               ctx->shm_size, total);
-    ap_rprintf(r, "subcaches: <b>%d</b>, indexes per subcache: <b>%d</b><br>",
-               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: <b>%d</b> seconds, (range: %d...%d)<br>",
-                       (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: <b>Calculation error!</b><br>");
+    /* Generate Output */
+    if (!(flags & AP_STATUS_SHORT)) {
+        ap_rprintf(r, "cache type: <b>SHMCB</b>, shared memory: <b>%" APR_SIZE_T_FMT "</b> "
+                   "bytes, current entries: <b>%d</b><br>",
+                   ctx->shm_size, total);
+        ap_rprintf(r, "subcaches: <b>%d</b>, indexes per subcache: <b>%d</b><br>",
+                   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: <b>%d</b> seconds, (range: %d...%d)<br>",
+                           (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: <b>Calculation error!</b><br>");
+        }
+
+        ap_rprintf(r, "index usage: <b>%d%%</b>, cache usage: <b>%d%%</b><br>",
+                   index_pct, cache_pct);
+        ap_rprintf(r, "total entries stored since starting: <b>%lu</b><br>",
+                   header->stat_stores);
+        ap_rprintf(r, "total entries replaced since starting: <b>%lu</b><br>",
+                   header->stat_replaced);
+        ap_rprintf(r, "total entries expired since starting: <b>%lu</b><br>",
+                   header->stat_expiries);
+        ap_rprintf(r, "total (pre-expiry) entries scrolled out of the cache: "
+                   "<b>%lu</b><br>", header->stat_scrolled);
+        ap_rprintf(r, "total retrieves since starting: <b>%lu</b> hit, "
+                   "<b>%lu</b> miss<br>", header->stat_retrieves_hit,
+                   header->stat_retrieves_miss);
+        ap_rprintf(r, "total removes since starting: <b>%lu</b> hit, "
+                   "<b>%lu</b> miss<br>", 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: <b>%d%%</b>, cache usage: <b>%d%%</b><br>",
-               index_pct, cache_pct);
-    ap_rprintf(r, "total entries stored since starting: <b>%lu</b><br>",
-               header->stat_stores);
-    ap_rprintf(r, "total entries replaced since starting: <b>%lu</b><br>",
-               header->stat_replaced);
-    ap_rprintf(r, "total entries expired since starting: <b>%lu</b><br>",
-               header->stat_expiries);
-    ap_rprintf(r, "total (pre-expiry) entries scrolled out of the cache: "
-               "<b>%lu</b><br>", header->stat_scrolled);
-    ap_rprintf(r, "total retrieves since starting: <b>%lu</b> hit, "
-               "<b>%lu</b> miss<br>", header->stat_retrieves_hit,
-               header->stat_retrieves_miss);
-    ap_rprintf(r, "total removes since starting: <b>%lu</b> hit, "
-               "<b>%lu</b> miss<br>", 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");
 }
 
index 3c6dce3469e68efd98e31c4266a89ff5a3168e18..609609f07ee84db62e8f52a64af7b76b4de41f17 100644 (file)
@@ -2683,58 +2683,80 @@ 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("<hr />\n<h1>Proxy LoadBalancer Status for ", r);
-        ap_rvputs(r, balancer->s->name, "</h1>\n\n", NULL);
-        ap_rputs("\n\n<table border=\"0\"><tr>"
-                 "<th>SSes</th><th>Timeout</th><th>Method</th>"
-                 "</tr>\n<tr>", r);
-        if (*balancer->s->sticky) {
-            if (strcmp(balancer->s->sticky, balancer->s->sticky_path)) {
-                ap_rvputs(r, "<td>", balancer->s->sticky, " | ",
-                          balancer->s->sticky_path, NULL);
+        if (!(flags & AP_STATUS_SHORT)) {
+            ap_rputs("<hr />\n<h1>Proxy LoadBalancer Status for ", r);
+            ap_rvputs(r, balancer->s->name, "</h1>\n\n", NULL);
+            ap_rputs("\n\n<table border=\"0\"><tr>"
+                     "<th>SSes</th><th>Timeout</th><th>Method</th>"
+                     "</tr>\n<tr>", r);
+            if (*balancer->s->sticky) {
+                if (strcmp(balancer->s->sticky, balancer->s->sticky_path)) {
+                    ap_rvputs(r, "<td>", balancer->s->sticky, " | ",
+                              balancer->s->sticky_path, NULL);
+                }
+                else {
+                    ap_rvputs(r, "<td>", balancer->s->sticky, NULL);
+                }
             }
             else {
-                ap_rvputs(r, "<td>", balancer->s->sticky, NULL);
+                ap_rputs("<td> - ", r);
             }
+            ap_rprintf(r, "</td><td>%" APR_TIME_T_FMT "</td>",
+                       apr_time_sec(balancer->s->timeout));
+            ap_rprintf(r, "<td>%s</td>\n",
+                       balancer->lbmethod->name);
+            ap_rputs("</table>\n", r);
+            ap_rputs("\n\n<table border=\"0\"><tr>"
+                     "<th>Sch</th><th>Host</th><th>Stat</th>"
+                     "<th>Route</th><th>Redir</th>"
+                     "<th>F</th><th>Set</th><th>Acc</th><th>Wr</th><th>Rd</th>"
+                     "</tr>\n", r);
         }
         else {
-            ap_rputs("<td> - ", r);
+            ap_rprintf(r, "ProxyBalancer[%d]Name: %s\n", i, balancer->s->name);
         }
-        ap_rprintf(r, "</td><td>%" APR_TIME_T_FMT "</td>",
-                   apr_time_sec(balancer->s->timeout));
-        ap_rprintf(r, "<td>%s</td>\n",
-                   balancer->lbmethod->name);
-        ap_rputs("</table>\n", r);
-        ap_rputs("\n\n<table border=\"0\"><tr>"
-                 "<th>Sch</th><th>Host</th><th>Stat</th>"
-                 "<th>Route</th><th>Redir</th>"
-                 "<th>F</th><th>Set</th><th>Acc</th><th>Wr</th><th>Rd</th>"
-                 "</tr>\n", r);
 
         worker = (proxy_worker **)balancer->workers->elts;
         for (n = 0; n < balancer->workers->nelts; n++) {
             char fbuf[50];
-            ap_rvputs(r, "<tr>\n<td>", (*worker)->s->scheme, "</td>", NULL);
-            ap_rvputs(r, "<td>", (*worker)->s->hostname, "</td><td>", NULL);
-            ap_rvputs(r, ap_proxy_parse_wstatus(r->pool, *worker), NULL);
-            ap_rvputs(r, "</td><td>", (*worker)->s->route, NULL);
-            ap_rvputs(r, "</td><td>", (*worker)->s->redirect, NULL);
-            ap_rprintf(r, "</td><td>%d</td>", (*worker)->s->lbfactor);
-            ap_rprintf(r, "<td>%d</td>", (*worker)->s->lbset);
-            ap_rprintf(r, "<td>%" APR_SIZE_T_FMT "</td><td>", (*worker)->s->elected);
-            ap_rputs(apr_strfsize((*worker)->s->transferred, fbuf), r);
-            ap_rputs("</td><td>", r);
-            ap_rputs(apr_strfsize((*worker)->s->read, fbuf), r);
-            ap_rputs("</td>\n", r);
-
-            /* TODO: Add the rest of dynamic worker data */
-            ap_rputs("</tr>\n", r);
+            if (!(flags & AP_STATUS_SHORT)) {
+                ap_rvputs(r, "<tr>\n<td>", (*worker)->s->scheme, "</td>", NULL);
+                ap_rvputs(r, "<td>", (*worker)->s->hostname, "</td><td>", NULL);
+                ap_rvputs(r, ap_proxy_parse_wstatus(r->pool, *worker), NULL);
+                ap_rvputs(r, "</td><td>", (*worker)->s->route, NULL);
+                ap_rvputs(r, "</td><td>", (*worker)->s->redirect, NULL);
+                ap_rprintf(r, "</td><td>%d</td>", (*worker)->s->lbfactor);
+                ap_rprintf(r, "<td>%d</td>", (*worker)->s->lbset);
+                ap_rprintf(r, "<td>%" APR_SIZE_T_FMT "</td><td>",
+                           (*worker)->s->elected);
+                ap_rputs(apr_strfsize((*worker)->s->transferred, fbuf), r);
+                ap_rputs("</td><td>", r);
+                ap_rputs(apr_strfsize((*worker)->s->read, fbuf), r);
+                ap_rputs("</td>\n", r);
+
+                /* TODO: Add the rest of dynamic worker data */
+                ap_rputs("</tr>\n", r);
+            }
+            else {
+                ap_rprintf(r, "ProxyBalancer[%d]Worker[%d]Name: %s\n",
+                           i, n, balancer->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;
         }
index 01f72546cdb8830aaec3fe9400f28887b2098bfa..2d365b221506eb674330ef44a651a34ecc64e530 100644 (file)
@@ -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("<hr>\n", r);
-    ap_rputs("<table cellspacing=0 cellpadding=0>\n", r);
-    ap_rputs("<tr><td bgcolor=\"#000000\">\n", r);
-    ap_rputs("<b><font color=\"#ffffff\" face=\"Arial,Helvetica\">SSL/TLS Session Cache Status:</font></b>\r", r);
-    ap_rputs("</td></tr>\n", r);
-    ap_rputs("<tr><td bgcolor=\"#ffffff\">\n", r);
+    if (!(flags & AP_STATUS_SHORT)) {
+        ap_rputs("<hr>\n", r);
+        ap_rputs("<table cellspacing=0 cellpadding=0>\n", r);
+        ap_rputs("<tr><td bgcolor=\"#000000\">\n", r);
+        ap_rputs("<b><font color=\"#ffffff\" face=\"Arial,Helvetica\">SSL/TLS Session Cache Status:</font></b>\r", r);
+        ap_rputs("</td></tr>\n", r);
+        ap_rputs("<tr><td bgcolor=\"#ffffff\">\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("</td></tr>\n", r);
-    ap_rputs("</table>\n", r);
+    if (!(flags & AP_STATUS_SHORT)) {
+        ap_rputs("</td></tr>\n", r);
+        ap_rputs("</table>\n", r);
+    }
+
     return OK;
 }