]> granicus.if.org Git - apache/commitdiff
Merge r1389565, r1389566, r1389569:
authorStefan Fritsch <sf@apache.org>
Sun, 9 Dec 2012 13:20:13 +0000 (13:20 +0000)
committerStefan Fritsch <sf@apache.org>
Sun, 9 Dec 2012 13:20:13 +0000 (13:20 +0000)
    Allow for exposure of loadavg and server load via mod_headers

    Might as well show 'em all

    Document new mod_headers params: %l, %i, %b

Submitted by: jim
Reviewed by: jailletc36, druggeri, minfrin

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1418937 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
STATUS
docs/manual/mod/mod_headers.xml
modules/metadata/mod_headers.c

diff --git a/CHANGES b/CHANGES
index f4a94db7cb969712257d394d2ee33bae49090065..50f6558e64d225d3081dc14b0eb23bdf83a711c1 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,9 @@
 
 Changes with Apache 2.4.4
 
+  *) mod_header: Allow for exposure of loadavg and server load using new 
+     format specifiers %l, %i, %b [Jim Jagielski]
+  
   *) core: Make ap_regcomp() return AP_REG_ESPACE if out of memory.  Make
      ap_pregcomp() abort if out of memory. This raises the minimum PCRE
      requirement to version 6.0. [Stefan Fritsch]
diff --git a/STATUS b/STATUS
index ed5708728fde8bf5b90d70613329c927c2261fac..da8d39227ec1a860812f72240c5f2f13a395e130 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -91,13 +91,6 @@ RELEASE SHOWSTOPPERS:
 PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
   [ start all new proposals below, under PATCHES PROPOSED. ]
 
-    * mod_headers: Allow for exposure of loadavg and server load via mod_headers
-      trunk patch: http://svn.apache.org/viewvc?view=revision&revision=1389565
-                   http://svn.apache.org/viewvc?view=revision&revision=1389566
-                   http://svn.apache.org/viewvc?view=revision&revision=1389569 (doc)
-      2.4.x patch: http://people.apache.org/~jailletc36/backport_mod_header.patch
-      +1: jailletc36, druggeri, minfrin
-
     * various mods: host and URI escaping
       trunk patch: http://svn.apache.org/viewvc?view=revision&revision=1413732
                    http://svn.apache.org/viewvc?view=revision&revision=1418752
index 620ee5c90fdddec01cd3236333e155df63dfe504..528e7f2d0d876e1b45e659240a460a320b74bed4 100644 (file)
@@ -427,6 +427,24 @@ Header merge Cache-Control no-store env=NO_STORE
         of the request. The value is preceded by <code>D=</code>.
         The value is measured in microseconds.</td></tr>
 
+    <tr><td><code>%l</code></td>
+        <td>The current load averages of the actual server itself. It is
+        designed to expose the values obtained by <code>getloadavg()</code>
+        and this represents the current load average, the 5 minute average, and
+        the 15 minute average. The value is preceded by <code>l=</code> with each
+        average separated by <code>/</code>.
+        </td></tr>
+
+    <tr><td><code>%i</code></td>
+        <td>The current idle percentage of httpd (0 to 100) based on available
+        processes and threads. The value is preceded by <code>i=</code>.
+        </td></tr>
+
+    <tr><td><code>%b</code></td>
+        <td>The current busy percentage of httpd (0 to 100) based on available
+        processes and threads. The value is preceded by <code>b=</code>.
+        </td></tr>
+
     <tr><td><code>%{VARNAME}e</code></td>
         <td>The contents of the <a href="../env.html">environment
         variable</a> <code>VARNAME</code>.</td></tr>
index d3a155569aa49c2409b765dd155438b45dfa1256..93977390b956e4642094049b9e27b3e639a22a44 100644 (file)
@@ -220,6 +220,28 @@ static const char *header_request_ssl_var(request_rec *r, char *name)
     }
 }
 
+static const char *header_request_loadavg(request_rec *r, char *a)
+{
+    ap_loadavg_t t;
+    ap_get_loadavg(&t);
+    return apr_psprintf(r->pool, "l=%.2f/%.2f/%.2f", t.loadavg,
+                        t.loadavg5, t.loadavg15);
+}
+
+static const char *header_request_idle(request_rec *r, char *a)
+{
+    ap_sload_t t;
+    ap_get_sload(&t);
+    return apr_psprintf(r->pool, "i=%d", t.idle);
+}
+
+static const char *header_request_busy(request_rec *r, char *a)
+{
+    ap_sload_t t;
+    ap_get_sload(&t);
+    return apr_psprintf(r->pool, "b=%d", t.busy);
+}
+
 /*
  * Config routines
  */
@@ -905,6 +927,9 @@ static int header_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp)
     register_format_tag_handler("t", header_request_time);
     register_format_tag_handler("e", header_request_env_var);
     register_format_tag_handler("s", header_request_ssl_var);
+    register_format_tag_handler("l", header_request_loadavg);
+    register_format_tag_handler("i", header_request_idle);
+    register_format_tag_handler("b", header_request_busy);
 
     return OK;
 }