From: Jim Jagielski Date: Mon, 28 Jan 2013 13:06:55 +0000 (+0000) Subject: Merge r1417529 from trunk: X-Git-Tag: 2.4.4~57 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fa16b1df0e46684a1c1115a229ecdb8fcebaf9b8;p=apache Merge r1417529 from trunk: Add useful mod_status info... try to determine last time a specific vhost was accessed/used. Reviewed/backported by: jim git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1439388 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/STATUS b/STATUS index 152f0112d2..d29d8c7b4c 100644 --- a/STATUS +++ b/STATUS @@ -96,16 +96,6 @@ PATCHES ACCEPTED TO BACKPORT FROM TRUNK: 2.4.x patch: trunk patch works +1: kbrand, jorton, jerenkrantz - * mod_status: Add useful mod_status info... try to determine last time - a specific vhost was accessed/used. - trunk patch: https://svn.apache.org/viewvc?view=revision&revision=1417529 - 2.4.x patch: trunk patch works - +1: jim, jerenkrantz, rjung - rjung: local variable "last_used" somehow misnamed (it is seconds since last used, - not like the time stamp of last use in the ws_record). Maybe "status_unchanged"? - rjung: The value is shown as "Seconds since last used". Actually it is more like - "Seconds since last slot status change", but that would be to ugly as a name. - * add new ap_bin2hex() utility function. This is needed to incorporate other changes that make use of this new function. trunk patch: http://svn.apache.org/viewvc?view=revision&revision=1422549 diff --git a/modules/generators/mod_status.c b/modules/generators/mod_status.c index 54404e90bb..0237f1d7f8 100644 --- a/modules/generators/mod_status.c +++ b/modules/generators/mod_status.c @@ -619,6 +619,7 @@ static int status_handler(request_rec *r) } if (ap_extended_status && !short_report) { + apr_table_t *vhosts = apr_table_make(r->pool, 10); if (no_table_report) ap_rputs("

Server Details

\n\n", r); else @@ -635,6 +636,10 @@ static int status_handler(request_rec *r) for (i = 0; i < server_limit; ++i) { for (j = 0; j < thread_limit; ++j) { + char *escvhost; + long last_used; + const char *vlast; + ws_record = ap_get_scoreboard_worker_from_indexes(i, j); if (ws_record->access_count == 0 && @@ -654,6 +659,22 @@ static int status_handler(request_rec *r) if (req_time < 0L) req_time = 0L; + escvhost = ap_escape_html(r->pool, ws_record->vhost); + last_used = (long)apr_time_sec(nowtime - ws_record->last_used); + if (escvhost && *escvhost) { + if ((vlast = apr_table_get(vhosts, escvhost)) != NULL) { + long temp = atol(vlast); + if (last_used < temp) { + apr_table_setn(vhosts, apr_pstrdup(r->pool, escvhost), + apr_psprintf(r->pool, "%ld", last_used)); + } + } + else { + apr_table_setn(vhosts, apr_pstrdup(r->pool, escvhost), + apr_psprintf(r->pool, "%ld", last_used)); + } + } + lres = ws_record->access_count; my_lres = ws_record->my_access_count; conn_lres = ws_record->conn_count; @@ -733,8 +754,7 @@ static int status_handler(request_rec *r) ws_record->times.tms_cutime / tick, ws_record->times.tms_cstime / tick, #endif - (long)apr_time_sec(nowtime - - ws_record->last_used), + last_used, (long) req_time); format_byte_out(r, conn_bytes); @@ -750,8 +770,7 @@ static int status_handler(request_rec *r) ap_escape_html(r->pool, ap_escape_logitem(r->pool, ws_record->request)), - ap_escape_html(r->pool, - ws_record->vhost)); + escvhost); } else { /* !no_table_report */ if (ws_record->status == SERVER_DEAD) @@ -820,8 +839,7 @@ static int status_handler(request_rec *r) ws_record->times.tms_cutime + ws_record->times.tms_cstime) / tick, #endif - (long)apr_time_sec(nowtime - - ws_record->last_used), + last_used, (long)req_time); ap_rprintf(r, "%-1.1f%-2.2f%-2.2f\n", @@ -832,8 +850,7 @@ static int status_handler(request_rec *r) "%s\n\n", ap_escape_html(r->pool, ws_record->client), - ap_escape_html(r->pool, - ws_record->vhost), + escvhost, ap_escape_html(r->pool, ap_escape_logitem(r->pool, ws_record->request))); @@ -842,6 +859,10 @@ static int status_handler(request_rec *r) } /* for (i...) */ if (!no_table_report) { + int i; + const apr_array_header_t *arr = apr_table_elts(vhosts); + const apr_table_entry_t *elts = (const apr_table_entry_t *)arr->elts; + ap_rputs("\n \
\ \n \ @@ -860,6 +881,13 @@ static int status_handler(request_rec *r) \n \ \n \
ChildMegabytes transferred this child
SlotTotal megabytes transferred this slot
\n", r); + ap_rputs("
\n\n\ +\n", r); + for (i = 0; i < arr->nelts; i++) { + ap_rprintf(r, "\n", + elts[i].key, elts[i].val); + } + ap_rputs("
VhostSeconds since last used
%s
%27s
\n", r); } } /* if (ap_extended_status && !short_report) */ else {