You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Jim Jagielski <ji...@jaguNET.com> on 1997/07/04 07:26:27 UTC

[PATCH] Get time required to process request in status module

This seemed the easiest and most straightforward way of doing this...

Index: apache/src/http_main.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_main.c,v
retrieving revision 1.173
diff -c -r1.173 http_main.c
*** http_main.c	1997/07/02 04:09:06	1.173
--- http_main.c	1997/07/04 05:21:41
***************
*** 1088,1093 ****
--- 1088,1096 ----
  {
      int old_status;
      short_score new_score_rec;
+ #if defined(STATUS)
+     struct tms tms_blk;
+ #endif
  
      if (child_num < 0)
  	return -1;
***************
*** 1111,1116 ****
--- 1114,1123 ----
  	new_score_rec.conn_count = (unsigned short)0;
  	new_score_rec.conn_bytes = (unsigned long)0;
      }
+     else if (status == SERVER_BUSY_WRITE) {
+ 	if ((new_score_rec.start_time = times(&tms_blk)) < 0)
+ 	    new_score_rec.start_time = (clock_t)0;
+     }
      if (r) {
  	int slot_size;
  	conn_rec *c = r->connection;
***************
*** 1156,1161 ****
--- 1163,1170 ----
  
      sync_scoreboard_image();
      new_score_rec = scoreboard_image->servers[child_num];
+     if ((new_score_rec.stop_time = times(&new_score_rec.times)) < 0)
+ 	new_score_rec.stop_time = new_score_rec.start_time = (clock_t)0;
      if (r->sent_bodyct)
          bgetopt(r->connection->client, BO_BYTECT, &bs);
  
***************
*** 1166,1173 ****
      new_score_rec.my_bytes_served += (unsigned long)bs;
      new_score_rec.conn_bytes += (unsigned long)bs;
  
-     times(&new_score_rec.times);
- 
      put_scoreboard_info(child_num, &new_score_rec); 
  }
  #endif
--- 1175,1180 ----
***************
*** 2241,2247 ****
  #if defined(STATUS)
              increment_counts(child_num, r);
  #endif
!             if (!current_conn->keepalive || current_conn->aborted)
                  break;
  
              destroy_pool(r->pool);
--- 2248,2254 ----
  #if defined(STATUS)
              increment_counts(child_num, r);
  #endif
!             if (!current_conn->keepalive || current_conn->aborted) 
                  break;
  
              destroy_pool(r->pool);
Index: apache/src/mod_status.c
===================================================================
RCS file: /export/home/cvs/apache/src/mod_status.c,v
retrieving revision 1.49
diff -c -r1.49 mod_status.c
*** mod_status.c	1997/07/03 21:27:23	1.49
--- mod_status.c	1997/07/04 05:21:42
***************
*** 204,209 ****
--- 204,210 ----
      unsigned short conn_lres;
      unsigned long bcount=0;
      unsigned long kbcount=0;
+     unsigned long req_time;
  #ifdef NEXT
      float tick=HZ;
  #else
***************
*** 286,295 ****
  	stat_buffer[i] = status[res];
          if (res == SERVER_READY)
  	    ready++;
!         else if (res == SERVER_BUSY_READ || res==SERVER_BUSY_WRITE || 
! 		 res == SERVER_STARTING || res==SERVER_BUSY_KEEPALIVE ||
! 		 res == SERVER_BUSY_LOG || res==SERVER_BUSY_DNS ||
! 		 res == SERVER_GRACEFUL)
  	    busy++;
  #if defined(STATUS)
          lres = score_record.access_count;
--- 287,293 ----
  	stat_buffer[i] = status[res];
          if (res == SERVER_READY)
  	    ready++;
!         else if (res != SERVER_DEAD && res != SERVER_UNKNOWN)
  	    busy++;
  #if defined(STATUS)
          lres = score_record.access_count;
***************
*** 428,442 ****
  	else
  #ifdef __EMX__
              /* Allow for OS/2 not having CPU stats */
!             rputs("<p>\n\n<table border=0><tr><th>Srv<th>PID<th>Acc<th>M\n<th>SS<th>Conn<th>Child<th>Slot<th>Host<th>VHost<th>Request</tr>\n\n",r);
  #else
!             rputs("<p>\n\n<table border=0><tr><th>Srv<th>PID<th>Acc<th>M<th>CPU\n<th>SS<th>Conn<th>Child<th>Slot<th>Host<th>VHost<th>Request</tr>\n\n",r);
  #endif
  
  
      for (i = 0; i<HARD_SERVER_LIMIT; ++i)
      {
          score_record=get_scoreboard_info(i);
          lres = score_record.access_count;
          my_lres = score_record.my_access_count;
  	conn_lres = score_record.conn_count;
--- 426,448 ----
  	else
  #ifdef __EMX__
              /* Allow for OS/2 not having CPU stats */
!             rputs("<p>\n\n<table border=0><tr><th>Srv<th>PID<th>Acc<th>M\n<th>SS<th>Req<th>Conn<th>Child<th>Slot<th>Host<th>VHost<th>Request</tr>\n\n",r);
  #else
!             rputs("<p>\n\n<table border=0><tr><th>Srv<th>PID<th>Acc<th>M<th>CPU\n<th>SS<th>Req<th>Conn<th>Child<th>Slot<th>Host<th>VHost<th>Request</tr>\n\n",r);
  #endif
  
  
      for (i = 0; i<HARD_SERVER_LIMIT; ++i)
      {
          score_record=get_scoreboard_info(i);
+ 	if ( score_record.start_time == (clock_t)0 
+ 	 || score_record.stop_time == (clock_t)0
+ 	 || (score_record.stop_time < score_record.start_time) )
+ 	    req_time = 0UL;
+ 	else {
+ 	    req_time = score_record.stop_time - score_record.start_time;
+ 	    req_time = (req_time*1000)/(int)tick;
+ 	}
          lres = score_record.access_count;
          my_lres = score_record.my_access_count;
  	conn_lres = score_record.conn_count;
***************
*** 492,507 ****
  		    }
  #ifdef __EMX__
                      /* Allow for OS/2 not having CPU stats */
!                     rprintf(r,"]\n %s (",
  #else
  
! 		    rprintf(r,"] u%g s%g cu%g cs%g\n %s (",
  			    score_record.times.tms_utime/tick,
  			    score_record.times.tms_stime/tick,
  			    score_record.times.tms_cutime/tick,
  			    score_record.times.tms_cstime/tick,
  #endif
! 			    asctime(localtime(&score_record.last_used)));
  		    format_byte_out(r,conn_bytes);
  		    rputs("|",r);
  		    format_byte_out(r,my_bytes);
--- 498,514 ----
  		    }
  #ifdef __EMX__
                      /* Allow for OS/2 not having CPU stats */
!                     rprintf(r,"]\n %.0f %ld (",
  #else
  
! 		    rprintf(r,"] u%g s%g cu%g cs%g\n %.0f %ld (",
  			    score_record.times.tms_utime/tick,
  			    score_record.times.tms_stime/tick,
  			    score_record.times.tms_cutime/tick,
  			    score_record.times.tms_cstime/tick,
  #endif
! 			    difftime(nowtime, score_record.last_used),
! 			    (long)req_time);
  		    format_byte_out(r,conn_bytes);
  		    rputs("|",r);
  		    format_byte_out(r,my_bytes);
***************
*** 556,570 ****
  		    }
  #ifdef __EMX__
  	            /* Allow for OS/2 not having CPU stats */
!         	    rprintf(r,"\n<td>%.0f",
  #else
! 		    rprintf(r,"\n<td>%.2f<td>%.0f",
  			    (score_record.times.tms_utime +
  			    score_record.times.tms_stime +
  			    score_record.times.tms_cutime +
  			    score_record.times.tms_cstime)/tick,
  #endif
! 			    difftime(nowtime, score_record.last_used));
  		    rprintf(r,"<td>%-1.1f<td>%-2.2f<td>%-2.2f\n",
  			(float)conn_bytes/KBYTE, (float)my_bytes/MBYTE,
  			(float)bytes/MBYTE);
--- 563,578 ----
  		    }
  #ifdef __EMX__
  	            /* Allow for OS/2 not having CPU stats */
!         	    rprintf(r,"\n<td>%.0f<td>%ld",
  #else
! 		    rprintf(r,"\n<td>%.2f<td>%.0f<td>%ld",
  			    (score_record.times.tms_utime +
  			    score_record.times.tms_stime +
  			    score_record.times.tms_cutime +
  			    score_record.times.tms_cstime)/tick,
  #endif
! 			    difftime(nowtime, score_record.last_used),
! 			    (long)req_time);
  		    rprintf(r,"<td>%-1.1f<td>%-2.2f<td>%-2.2f\n",
  			(float)conn_bytes/KBYTE, (float)my_bytes/MBYTE,
  			(float)bytes/MBYTE);
***************
*** 587,592 ****
--- 595,601 ----
  <tr><th>Acc<td>Number of accesses this connection / this child / this slot\n \
  <tr><th>M<td>Mode of operation\n \
  <tr><th>SS<td>Seconds since beginning of most recent request\n \
+ <tr><th>Req<td>Milliseconds required to process most recent request\n \
  <tr><th>Conn<td>Kilobytes transferred this connection\n \
  <tr><th>Child<td>Megabytes transferred this child\n \
  <tr><th>Slot<td>Total megabytes transferred this slot\n \
***************
*** 601,606 ****
--- 610,616 ----
  <tr><th>M<td>Mode of operation\n \
  <tr><th>CPU<td>CPU usage, number of seconds\n \
  <tr><th>SS<td>Seconds since beginning of most recent request\n \
+ <tr><th>Req<td>Milliseconds required to process most recent request\n \
  <tr><th>Conn<td>Kilobytes transferred this connection\n \
  <tr><th>Child<td>Megabytes transferred this child\n \
  <tr><th>Slot<td>Total megabytes transferred this slot\n \
Index: apache/src/scoreboard.h
===================================================================
RCS file: /export/home/cvs/apache/src/scoreboard.h,v
retrieving revision 1.23
diff -c -r1.23 scoreboard.h
*** scoreboard.h	1997/06/24 00:32:32	1.23
--- scoreboard.h	1997/07/04 05:21:42
***************
*** 85,90 ****
--- 85,92 ----
      unsigned long my_bytes_served;
      unsigned long conn_bytes;
      unsigned short conn_count;
+     clock_t start_time;
+     clock_t stop_time;
      struct tms times;
      time_t last_used;
      char client[32];	/* Keep 'em small... */
-- 
====================================================================
      Jim Jagielski            |       jaguNET Access Services
     jim@jaguNET.com           |       http://www.jaguNET.com/
            "Look at me! I'm wearing a cardboard belt!"