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 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]
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
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>
}
}
+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
*/
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;
}