]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
mod_status: Add cumulated response duration time
authorRainer Jung <rjung@apache.org>
Wed, 29 Aug 2018 03:09:18 +0000 (03:09 +0000)
committerRainer Jung <rjung@apache.org>
Wed, 29 Aug 2018 03:09:18 +0000 (03:09 +0000)
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

CHANGES
STATUS
include/ap_mmn.h
include/scoreboard.h
modules/generators/mod_status.c
server/scoreboard.c

diff --git a/CHANGES b/CHANGES
index 998ce74d0f0389b541198230f0eae95b208f3ffd..ad354e08eb16964406d2508a450c162595e9046b 100644 (file)
--- 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 86ca4628f1d861dd5f83fdc7b41ba07e5c7a005c..2e11bbe0831c7e800024223e30c4ea5d4e0b2f00 100644 (file)
--- 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 ]
index c7d3b8f3fe6484b5e331e3941bf69e7e66ee66b7..e2bd6ac81e39f01485fcfd667fcfef3393f84171 100644 (file)
  * 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
  *
  */
 
 #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
index 52a582cc9598b5f8ef0c874d7378b8a6457d4803..4c846b5f36ba36ca03b0b61bd8211776259d3473 100644 (file)
@@ -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 {
index a2ba214e28958ffbd834557b4173352e5d31df85..52d183a128b12a7ce9b3786612e0646af3015b61 100644 (file)
@@ -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, "<dt>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("</dt>\n", r);
index 720f06bb6136d92b13502e70aee15edfebaf4d15..b25fed00f8f3fd030f7599939a2f296390354e90 100644 (file)
@@ -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;
+        }
     }
 }