httpd-test-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pt...@pobox.com
Subject [PATCH] flood: (Updated) Add handler relative_times_sizes_process_stats
Date Thu, 13 Feb 2003 09:16:46 GMT
Summary:
  [PATCH] flood: (Updated) Add handler relative_times_sizes_process_stats

This patch is an update of the original patch I sent February 7,
2003 to have report_relative include the bytes sent and received when
displaying statistics.  I updated it against the current public source
from CVS  and included the follow-up bugfix I sent later that day.

Please consider this patch experimental.  I'm adding a new handler
so that the statistics from report_relative includes the request and
response sizes.  An alternate solution might be to allow the configuration
to specify which columns to output.  For example:
  <process_stats columns="start,close,sent,received,status,id,url">
    relative_times_process_stats
  </process_stats>
The default would be the current set of statistics.  I'm not sure
I like that additional attribute, because not all process_stats
handlers would respect the attribute.  Food for thought ...

Affected files:
  flood_profile.c
  flood_report_relative_times.c
  flood_report_relative_times.h

This patch adds an alternative to the handler:
  relative_times_process_stats
The new handler:
  relative_times_sizes_process_stats
includes the number of bytes sent in the request and received in the
response.  This patch retrieves the number of bytes sent and received
from data member "rbufsize" in the request (request_t) and response
(response_t) structures.

To report the true bytes sent and received, you should specify the
following handler in your profile:
  <recv_resp>generic_fullresp_recv_resp</recv_resp>

The new handler allows you to calculate the bytes sent and received
along with the time spent sending and receiving the data.  The new
columns precede the response status:
  start, connect, write, read, close, sent, received, status, thread/process ID, url
Here's a sample (the "112" and "1460" are new):
  1044589747892106 40058 40058 40058 40058 112 1460 OK  108 http://localhost/

Index: flood_profile.c
===================================================================
RCS file: /home/cvspublic/httpd-test/flood/flood_profile.c,v
retrieving revision 1.24
diff -u -r1.24 flood_profile.c
--- flood_profile.c	12 Feb 2003 22:50:58 -0000	1.24
+++ flood_profile.c	13 Feb 2003 08:41:31 -0000
@@ -290,6 +290,7 @@
     /* Relative Times Report */
     {"report_init",      "relative_times_report_init",   &relative_times_report_init},
     {"process_stats",    "relative_times_process_stats", &relative_times_process_stats},
+    {"process_stats",    "relative_times_sizes_process_stats", &relative_times_sizes_process_stats},
     {"report_stats",     "relative_times_report_stats",  &relative_times_report_stats},
     {"destroy_report",   "relative_times_destroy_report",&relative_times_destroy_report},
 
Index: flood_report_relative_times.c
===================================================================
RCS file: /home/cvspublic/httpd-test/flood/flood_report_relative_times.c,v
retrieving revision 1.6
diff -u -r1.6 flood_report_relative_times.c
--- flood_report_relative_times.c	3 Feb 2003 17:10:56 -0000	1.6
+++ flood_report_relative_times.c	13 Feb 2003 08:41:31 -0000
@@ -76,31 +76,22 @@
     return APR_SUCCESS;
 }
 
-apr_status_t relative_times_process_stats(report_t *report, int verified, request_t *req,
response_t *resp, flood_timer_t *timer)
+static apr_status_t process_stats_tail(char *buf,
+                                       apr_size_t buflen,
+                                       const apr_size_t maxlen,
+                                       int verified,
+                                       const request_t *req)
 {
-#define FLOOD_PRINT_BUF 256
-    apr_size_t buflen;
-    char buf[FLOOD_PRINT_BUF];
-
-    buflen = apr_snprintf(buf, FLOOD_PRINT_BUF,
-                          "%" APR_INT64_T_FMT " %" APR_INT64_T_FMT
-                          " %" APR_INT64_T_FMT " %" APR_INT64_T_FMT " %" APR_INT64_T_FMT,
-                          timer->begin,
-                          timer->connect - timer->begin,
-                          timer->write - timer->begin,
-                          timer->read - timer->begin,
-                          timer->close - timer->begin);
-
     switch (verified)
     {
     case FLOOD_VALID:
-        apr_snprintf(buf+buflen, FLOOD_PRINT_BUF-buflen, " OK ");
+        apr_snprintf(buf + buflen, maxlen - buflen, " OK ");
         break;
     case FLOOD_INVALID:
-        apr_snprintf(buf+buflen, FLOOD_PRINT_BUF-buflen, " FAIL ");
+        apr_snprintf(buf + buflen, maxlen - buflen, " FAIL ");
         break;
     default:
-        apr_snprintf(buf+buflen, FLOOD_PRINT_BUF-buflen, " %d ", verified);
+        apr_snprintf(buf + buflen, maxlen - buflen, " %d ", verified);
     }
 
     /* FIXME: this call may need to be in a critical section */
@@ -111,6 +102,54 @@
 #endif
 
     return APR_SUCCESS;
+}
+
+/* The buffer size was changed from 256 to 384 to help accommodate
+   large URLs and several 64-bit integers. */
+#define FLOOD_PRINT_BUF 384
+
+apr_status_t relative_times_process_stats(report_t *report,
+                                          int verified,
+                                          request_t *req,
+                                          response_t *resp,
+                                          flood_timer_t *timer)
+{
+    apr_size_t buflen;
+    char buf[FLOOD_PRINT_BUF];
+
+    buflen = apr_snprintf(buf, sizeof(buf),
+                          "%" APR_INT64_T_FMT " %" APR_INT64_T_FMT
+                          " %" APR_INT64_T_FMT " %" APR_INT64_T_FMT " %" APR_INT64_T_FMT,
+                          timer->begin,
+                          timer->connect - timer->begin,
+                          timer->write - timer->begin,
+                          timer->read - timer->begin,
+                          timer->close - timer->begin);
+
+    return process_stats_tail(buf, buflen, sizeof(buf), verified, req);
+}
+
+apr_status_t relative_times_sizes_process_stats(report_t *report,
+                                                int verified,
+                                                request_t *req,
+                                                response_t *resp,
+                                                flood_timer_t *timer)
+{
+    apr_size_t buflen;
+    char buf[FLOOD_PRINT_BUF];
+
+    buflen = apr_snprintf(buf, sizeof(buf),
+                          "%" APR_INT64_T_FMT " %" APR_INT64_T_FMT
+                          " %" APR_INT64_T_FMT " %" APR_INT64_T_FMT " %" APR_INT64_T_FMT
+                          " %" APR_SIZE_T_FMT " %" APR_SIZE_T_FMT,
+                          timer->begin,
+                          timer->connect - timer->begin,
+                          timer->write - timer->begin,
+                          timer->read - timer->begin,
+                          timer->close - timer->begin,
+                          req->rbufsize, resp->rbufsize);
+
+    return process_stats_tail(buf, buflen, sizeof(buf), verified, req);
 }
 
 apr_status_t relative_times_report_stats(report_t *report)
Index: flood_report_relative_times.h
===================================================================
RCS file: /home/cvspublic/httpd-test/flood/flood_report_relative_times.h,v
retrieving revision 1.2
diff -u -r1.2 flood_report_relative_times.h
--- flood_report_relative_times.h	3 Feb 2003 17:10:56 -0000	1.2
+++ flood_report_relative_times.h	13 Feb 2003 08:41:31 -0000
@@ -66,6 +66,8 @@
 
 apr_status_t relative_times_process_stats(report_t *report, int verified, request_t *req,
response_t *resp, flood_timer_t *timer);
 
+apr_status_t relative_times_sizes_process_stats(report_t *report, int verified, request_t
*req, response_t *resp, flood_timer_t *timer);
+
 apr_status_t relative_times_report_stats(report_t *report);
 
 apr_status_t relative_times_destroy_report(report_t *report);

Mime
View raw message