From: Rainer Jung Date: Wed, 29 Aug 2018 03:09:18 +0000 (+0000) Subject: mod_status: Add cumulated response duration time X-Git-Tag: 2.4.35~44 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9d0e918836abdd7d5089eb054a1a3de90af99b42;p=thirdparty%2Fapache%2Fhttpd.git mod_status: Add cumulated response duration time in milliseconds to auto mode. Partial backport of r1839532 from trunk (only auto mode changes, html parts not yet backported). Submitted by: rjung Reviewed by: rjung, jim, ylavic git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1839533 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 998ce74d0f0..ad354e08eb1 100644 --- a/CHANGES +++ b/CHANGES @@ -10,6 +10,10 @@ Changes with Apache 2.4.35 "ProxyStatus" is "On": add "busy" count to auto mode and show byte counts in auto mode always in units of kilobytes. [Rainer Jung] + *) mod_status: Add cumulated response duration time in milliseconds + to auto mode. + [Rainer Jung] + *) mod_status: Complete the data shown for async MPMs in "auto" mode. Added number of processes, number of stopping processes and number of busy and idle workers. [Rainer Jung] diff --git a/STATUS b/STATUS index 86ca4628f1d..2e11bbe0831 100644 --- a/STATUS +++ b/STATUS @@ -147,13 +147,6 @@ PATCHES ACCEPTED TO BACKPORT FROM TRUNK: 2.4.x patch: http://people.apache.org/~covener/2.4.x-proxy-opt-fn.diff +1: covener, jim, ylavic - *) mod_status: Add cumulated response duration time - in milliseconds. - trunk: http://svn.apache.org/r1837590 - 2.4.x patch: svn merge -c 1837590 ^/httpd/httpd/trunk . - (adjust CHANGES and include/ap_mmn.h) - +1: rjung, jim, ylavic - PATCHES PROPOSED TO BACKPORT FROM TRUNK: [ New proposals should be added at the end of the list ] diff --git a/include/ap_mmn.h b/include/ap_mmn.h index c7d3b8f3fe6..e2bd6ac81e3 100644 --- a/include/ap_mmn.h +++ b/include/ap_mmn.h @@ -518,6 +518,8 @@ * 20120211.80 (2.4.35-dev) Add new ap_update_global_status() method and * times field in the global_score structure in * scoreboard.h. + * 20120211.81 (2.4.35-dev) Add new duration field to worker_score struct in + * scoreboard.h * */ @@ -526,7 +528,7 @@ #ifndef MODULE_MAGIC_NUMBER_MAJOR #define MODULE_MAGIC_NUMBER_MAJOR 20120211 #endif -#define MODULE_MAGIC_NUMBER_MINOR 80 /* 0...n */ +#define MODULE_MAGIC_NUMBER_MINOR 81 /* 0...n */ /** * Determine if the server's current MODULE_MAGIC_NUMBER is at least a diff --git a/include/scoreboard.h b/include/scoreboard.h index 52a582cc959..4c846b5f36b 100644 --- a/include/scoreboard.h +++ b/include/scoreboard.h @@ -116,6 +116,7 @@ struct worker_score { char request[64]; /* We just want an idea... */ char vhost[32]; /* What virtual host is being accessed? */ char protocol[16]; /* What protocol is used on the connection? */ + apr_time_t duration; }; typedef struct { diff --git a/modules/generators/mod_status.c b/modules/generators/mod_status.c index a2ba214e289..52d183a128b 100644 --- a/modules/generators/mod_status.c +++ b/modules/generators/mod_status.c @@ -193,6 +193,7 @@ static int status_handler(request_rec *r) apr_off_t bytes, my_bytes, conn_bytes; apr_off_t bcount, kbcount; long req_time; + apr_time_t duration_global; int short_report; int no_table_report; global_score *global_record; @@ -234,6 +235,7 @@ static int status_handler(request_rec *r) count = 0; bcount = 0; kbcount = 0; + duration_global = 0; short_report = 0; no_table_report = 0; @@ -385,6 +387,7 @@ static int status_handler(request_rec *r) count += lres; bcount += bytes; + duration_global += ws_record->duration; if (bcount >= KBYTE) { kbcount += (bcount >> 10); @@ -473,8 +476,9 @@ static int status_handler(request_rec *r) clock_t cpu = gu + gs + gcu + gcs + tu + ts + tcu + tcs; if (short_report) { ap_rprintf(r, "Total Accesses: %lu\nTotal kBytes: %" - APR_OFF_T_FMT "\n", - count, kbcount); + APR_OFF_T_FMT "\nTotal Duration: %" + APR_TIME_T_FMT "\n", + count, kbcount, duration_global / 1000); #ifdef HAVE_TIMES /* Allow for OS/2 not having CPU stats */ @@ -494,9 +498,12 @@ static int status_handler(request_rec *r) ap_rprintf(r, "BytesPerSec: %g\n", KBYTE * (float) kbcount / (float) up_time); } - if (count > 0) + if (count > 0) { ap_rprintf(r, "BytesPerReq: %g\n", KBYTE * (float) kbcount / (float) count); + ap_rprintf(r, "DurationPerReq: %g\n", + (float) duration_global / (float) count / 1000.); + } } else { /* !short_report */ ap_rprintf(r, "
Total accesses: %lu - Total Traffic: ", count); @@ -530,7 +537,8 @@ static int status_handler(request_rec *r) ap_rputs(" - ", r); format_byte_out(r, (unsigned long)(KBYTE * (float) kbcount / (float) count)); - ap_rputs("/request", r); + ap_rprintf(r, "/request - %g ms/request", + (float) duration_global / (float) count / 1000.); } ap_rputs("
\n", r); diff --git a/server/scoreboard.c b/server/scoreboard.c index 720f06bb613..b25fed00f8f 100644 --- a/server/scoreboard.c +++ b/server/scoreboard.c @@ -627,6 +627,9 @@ AP_DECLARE(void) ap_time_process_request(ap_sb_handle_t *sbh, int status) } else if (status == STOP_PREQUEST) { ws->stop_time = ws->last_used = apr_time_now(); + if (ap_extended_status) { + ws->duration += ws->stop_time - ws->start_time; + } } }