From: Stefan Fritsch Date: Sun, 9 Dec 2012 13:20:13 +0000 (+0000) Subject: Merge r1389565, r1389566, r1389569: X-Git-Tag: 2.4.4~349 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dcc145f19676b55f6fe1446926964f003f70670b;p=apache Merge r1389565, r1389566, r1389569: 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 --- diff --git a/CHANGES b/CHANGES index f4a94db7cb..50f6558e64 100644 --- 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 ed5708728f..da8d39227e 100644 --- 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 diff --git a/docs/manual/mod/mod_headers.xml b/docs/manual/mod/mod_headers.xml index 620ee5c90f..528e7f2d0d 100644 --- a/docs/manual/mod/mod_headers.xml +++ b/docs/manual/mod/mod_headers.xml @@ -427,6 +427,24 @@ Header merge Cache-Control no-store env=NO_STORE of the request. The value is preceded by D=. The value is measured in microseconds. + %l + The current load averages of the actual server itself. It is + designed to expose the values obtained by getloadavg() + and this represents the current load average, the 5 minute average, and + the 15 minute average. The value is preceded by l= with each + average separated by /. + + + %i + The current idle percentage of httpd (0 to 100) based on available + processes and threads. The value is preceded by i=. + + + %b + The current busy percentage of httpd (0 to 100) based on available + processes and threads. The value is preceded by b=. + + %{VARNAME}e The contents of the environment variable VARNAME. diff --git a/modules/metadata/mod_headers.c b/modules/metadata/mod_headers.c index d3a155569a..93977390b9 100644 --- a/modules/metadata/mod_headers.c +++ b/modules/metadata/mod_headers.c @@ -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; }