jim         96/05/07 11:29:38

  Modified:    src       http_main.c mod_status.c scoreboard.h
  Log:
  status module improvements + tables
  
  Revision  Changes    Path
  1.25      +11 -3     apache/src/http_main.c
  
  Index: http_main.c
  ===================================================================
  RCS file: /export/home/cvs/apache/src/http_main.c,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -C3 -r1.24 -r1.25
  *** http_main.c       1996/04/18 11:16:36     1.24
  --- http_main.c       1996/05/07 18:29:34     1.25
  ***************
  *** 672,677 ****
  --- 672,679 ----
         */
        new_score_rec.my_access_count = 0L;
        new_score_rec.my_bytes_served = 0L;
  +     new_score_rec.conn_count = (unsigned short)0;
  +     new_score_rec.conn_bytes = (unsigned short)0;
        }
        if (r) {
        int slot_size;
  ***************
  *** 713,719 ****
    }
    
    #if defined(STATUS)
  ! void increment_counts (int child_num, request_rec *r)
    {
        long int bs=0;
        short_score new_score_rec=scoreboard_image[child_num];
  --- 715,721 ----
    }
    
    #if defined(STATUS)
  ! void increment_counts (int child_num, request_rec *r, int flag)
    {
        long int bs=0;
        short_score new_score_rec=scoreboard_image[child_num];
  ***************
  *** 721,730 ****
  --- 723,738 ----
        if (r->sent_bodyct)
            bgetopt(r->connection->client, BO_BYTECT, &bs);
    
  +     if (flag) {
  +     new_score_rec.conn_count = (unsigned short)0;
  +     new_score_rec.conn_bytes = (unsigned short)0;
  +     }
        new_score_rec.access_count ++;
        new_score_rec.my_access_count ++;
  +     new_score_rec.conn_count ++;
        new_score_rec.bytes_served += (unsigned long)bs;
        new_score_rec.my_bytes_served += (unsigned long)bs;
  +     new_score_rec.conn_bytes += (unsigned short)bs;
    
        times(&new_score_rec.times);
    
  ***************
  *** 1176,1182 ****
        if (r) process_request (r); /* else premature EOF --- ignore */
    
    #if defined(STATUS)
  !         if (r) increment_counts(child_num,r);
    #endif
        while (r && current_conn->keepalive) {
          bflush(conn_io);
  --- 1184,1190 ----
        if (r) process_request (r); /* else premature EOF --- ignore */
    
    #if defined(STATUS)
  !         if (r) increment_counts(child_num,r,1);
    #endif
        while (r && current_conn->keepalive) {
          bflush(conn_io);
  ***************
  *** 1187,1193 ****
          if (r) process_request (r);
    
    #if defined(STATUS)
  !       if (r) increment_counts(child_num,r);
    #endif
        }
    #if 0       
  --- 1195,1201 ----
          if (r) process_request (r);
    
    #if defined(STATUS)
  !       if (r) increment_counts(child_num,r,0);
    #endif
        }
    #if 0       
  
  
  
  1.15      +336 -143  apache/src/mod_status.c
  
  Index: mod_status.c
  ===================================================================
  RCS file: /export/home/cvs/apache/src/mod_status.c,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -C3 -r1.14 -r1.15
  *** mod_status.c      1996/04/17 00:30:58     1.14
  --- mod_status.c      1996/05/07 18:29:35     1.15
  ***************
  *** 61,66 ****
  --- 61,67 ----
     * GET /.status?refresh - Returns page with 1 second refresh
     * GET /.status?refresh=6 - Returns page with refresh every 6 seconds
     * GET /.status?auto - Returns page with data for automatic parsing
  +  * GET /.status?notable - Returns page with no table niceties
     *
     * Mark Cox, [EMAIL PROTECTED], November 1995
     *
  ***************
  *** 72,77 ****
  --- 73,80 ----
     * 25.3.96  Show uptime better [Mark/Ben Laurie]
     * 29.3.96  Better HTML and explanation [Mark/Rob Hartill suggested]
     * 09.4.96  Added message for non-STATUS compiled version
  +  * 18.4.96  Added per child and per slot counters [Jim Jagielski]
  +  * 01.5.96  Table format, cleanup, even more spiffy data [Chuck Murcko/Jim 
J.]
     */
    
    #include "httpd.h"
  ***************
  *** 83,103 ****
    #include <time.h>
    #include "scoreboard.h"
    
    module status_module;
    
    /* Format the number of bytes nicely */
    
  ! void format_byte_out(request_rec *r,unsigned long bytes) {
        char ss[20];
    
  !     if (bytes<5196)
            sprintf(ss,"%dB",(int)bytes);
  !     else if (bytes<524288)
  !     sprintf(ss,"%.1fkB",(float)bytes/1024);
  !     else if (bytes<536870912)
  !     sprintf(ss,"%.1fMB",(float)bytes/1048576);
        else
  !     sprintf(ss,"%.1fGB",(float)bytes/1073741824);
        rputs(ss,r);
    }
    
  --- 86,113 ----
    #include <time.h>
    #include "scoreboard.h"
    
  + #define STATUS_MAXLINE              50
  + 
  + #define KBYTE                       1024
  + #define     MBYTE                   1048576L
  + #define     GBYTE                   1073741824L
  + 
    module status_module;
    
    /* Format the number of bytes nicely */
    
  ! void format_byte_out(request_rec *r,unsigned long bytes)
  ! {
        char ss[20];
    
  !     if (bytes < (5 * KBYTE))
            sprintf(ss,"%dB",(int)bytes);
  !     else if (bytes < (MBYTE / 2))
  !     sprintf(ss,"%.1fkB",(float)bytes/KBYTE);
  !     else if (bytes < (GBYTE / 2))
  !     sprintf(ss,"%.1fMB",(float)bytes/MBYTE);
        else
  !     sprintf(ss,"%.1fGB",(float)bytes/GBYTE);
        rputs(ss,r);
    }
    
  ***************
  *** 116,135 ****
        s=buf;
        *s='\0';
        if(days)
  !       s+=sprintf(s," %ld day%s",days,days==1?"":"s");
        if(hrs)
  !       s+=sprintf(s," %ld hour%s",hrs,hrs==1?"":"s");
        if(mins)
  !       s+=sprintf(s," %ld minute%s",mins,mins==1?"":"s");
        if(secs)
  !       s+=sprintf(s," %ld second%s",secs,secs==1?"":"s");
        rputs(buf,r);
    }
    
    /* Main handler for x-httpd-status requests */
    
    int status_handler (request_rec *r)
    {
        time_t nowtime=time(NULL);
        time_t up_time;
        int i,res;
  --- 126,179 ----
        s=buf;
        *s='\0';
        if(days)
  !     {
  !       sprintf(s," %ld day%s",days,days==1?"":"s");
  !       s+=strlen(s);
  !     }
        if(hrs)
  !     {
  !       sprintf(s," %ld hour%s",hrs,hrs==1?"":"s");
  !       s+=strlen(s);
  !     }
        if(mins)
  !     {
  !       sprintf(s," %ld minute%s",mins,mins==1?"":"s");
  !       s+=strlen(s);
  !     }
        if(secs)
  !     {
  !       sprintf(s," %ld second%s",secs,secs==1?"":"s");
  !       s+=strlen(s);
  !     }
        rputs(buf,r);
    }
    
    /* Main handler for x-httpd-status requests */
    
  + /* ID values for command table */
  + 
  + #define STAT_OPT_END                -1
  + #define STAT_OPT_REFRESH    0
  + #define STAT_OPT_NOTABLE    1
  + #define STAT_OPT_AUTO               2
  + 
  + struct stat_opt
  + {
  +     int id;
  +     char *form_data_str;
  +     char *hdr_out_str;
  + };
  + 
    int status_handler (request_rec *r)
    {
  +     struct stat_opt options[] =        /* see #defines above */
  +     {
  +     STAT_OPT_REFRESH, "refresh", "Refresh",
  +         STAT_OPT_NOTABLE, "notable", NULL,
  +         STAT_OPT_AUTO, "auto", NULL,
  +     STAT_OPT_END, NULL, NULL
  +     };
  +     char *loc;
        time_t nowtime=time(NULL);
        time_t up_time;
        int i,res;
  ***************
  *** 139,152 ****
        unsigned long count=0;
        unsigned long lres,bytes;
        unsigned long my_lres,my_bytes;
        unsigned long bcount=0;
        float tick=sysconf(_SC_CLK_TCK);
  ! #endif
        int short_report=0;
        server_rec *server = r->server;
        short_score score_record;
        char status[]="???????";
        char buffer[200];
        clock_t tu,ts,tcu,tcs;
    
        tu=ts=tcu=tcs=0;
  --- 183,199 ----
        unsigned long count=0;
        unsigned long lres,bytes;
        unsigned long my_lres,my_bytes;
  +     unsigned short conn_lres,conn_bytes;
        unsigned long bcount=0;
        float tick=sysconf(_SC_CLK_TCK);
  ! #endif /* STATUS */
        int short_report=0;
  +     int no_table_report=0;
        server_rec *server = r->server;
        short_score score_record;
        char status[]="???????";
        char buffer[200];
  +     char stat_buffer[HARD_SERVER_MAX];
        clock_t tu,ts,tcu,tcs;
    
        tu=ts=tcu=tcs=0;
  ***************
  *** 160,273 ****
        if (r->method_number != M_GET) return NOT_IMPLEMENTED;
        r->content_type = "text/html";
    
  !     if (r->args) {
  !         if (!strncmp(r->args,"refresh",7))
  !       if(r->args[7] == '=')
  !         table_set(r->headers_out,"Refresh",r->args+8);
  !       else
  !         table_set(r->headers_out,"Refresh","1");
  !         else if (!strncmp(r->args,"auto",4)) {
  !       r->content_type = "text/plain";
  !       short_report=1;
  !     }
        }
        soft_timeout ("send status info", r);
        send_http_header(r);
    
        if (r->header_only) 
        return 0;
    
  -     up_time=nowtime-restart_time;
  - 
  -     if (!short_report) {
  -         rputs("<html><head><title>Apache Status</title></head><body>",r);
  -         rputs("<h1>Apache Server Status</h1>\n\n",r);
  -     rvputs(r,"Hostname: ",server->server_hostname,"<br>",NULL);
  -     rvputs(r,"Current Time: ",asctime(localtime(&nowtime)),"<br>",NULL);
  -     rvputs(r,"Restart Time: ",asctime(localtime(&restart_time)),"<br>",
  -            NULL);
  -     rputs("Server up for: ",r);
  -     show_time(r,up_time);
  -     rputs("<p>",r);
  -     }
  - 
        sync_scoreboard_image();
  !     rputs("Scoreboard: ",r);
  !     if(!short_report)
  !     rputs("<PRE>",r);
  !     for (i = 0; i<HARD_SERVER_MAX; ++i) {
            score_record = get_scoreboard_info(i);
            res = score_record.status;
  !     rputc(status[res],r);
            if (res == SERVER_READY)
            ready++;
            else if (res == SERVER_BUSY_READ || res==SERVER_BUSY_WRITE || 
                 res == SERVER_STARTING)
            busy++;
  -     if(!short_report && i%25 == 24)
  -         rputs("\r\n",r);
  -     }
  -     if(!short_report) {
  -     rputs("</PRE>",r);
  -     rputs("Key: ",r);
  -     rputs("\"<code>_</code>\" Waiting for Connection, ",r);
  -     rputs("\"<code>S</code>\" Starting up, ",r);
  -     rputs("\"<code>R</code>\" Reading Request, ",r);
  -     rputs("\"<code>W</code>\" Sending Reply<p>",r);
  -     }
  -     if (short_report)
  -         sprintf(buffer,"\nBusyServers: %d\nIdleServers: %d\n",busy,ready);
  -     else 
  -         sprintf(buffer,"\n%d requests currently being processed,\n %d idle 
servers\n",busy,ready);
  -     rputs(buffer,r);
  - 
    #if defined(STATUS)
  -     if (!short_report)
  -       rputs("<hr><h2>Server Details</h2>",r);
  -     for (i = 0; i<HARD_SERVER_MAX; ++i) {
  -         score_record=get_scoreboard_info(i);
            lres = score_record.access_count;
  -         my_lres = score_record.my_access_count;
        bytes= score_record.bytes_served;
  !     my_bytes= score_record.my_bytes_served;
  !         if (lres!=0 || (score_record.status != SERVER_READY && 
score_record.status != SERVER_DEAD)) {
  !         if (!short_report) {
  !             sprintf(buffer,"<b>Server %d</b> (%d): %lu|%lu [",
  !              i,(int)score_record.pid,my_lres,lres);
  !             rputs(buffer,r);
  ! 
  !             switch (score_record.status) {
  !             case SERVER_READY:
  !                 rputs("Ready",r);
  !                 break;
  !             case SERVER_STARTING:
  !                 rputs("Starting",r);
  !                 break;
  !             case SERVER_BUSY_READ:
  !                 rputs("<b>Read</b>",r);
  !                 break;
  !             case SERVER_BUSY_WRITE:
  !                 rputs("<b>Write</b>",r);
  !                 break;
  !             case SERVER_DEAD:
  !                 rputs("Dead",r);
  !                 break;
  !             }
  !             sprintf(buffer,"] u%g s%g cu%g cs%g %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,
  !                     asctime(localtime(&score_record.last_used)));
  !             rputs(buffer,r);
  !             format_byte_out(r,my_bytes);
  !             rputs("|",r);
  !             format_byte_out(r,bytes);
  !             rputs(")",r);
  !             sprintf(buffer," <i>%s {%s}</i><br>", score_record.client,
  !                     score_record.request);
  !             rputs(buffer,r);
  !         }
            tu+=score_record.times.tms_utime;
            ts+=score_record.times.tms_stime;
            tcu+=score_record.times.tms_cutime;
  --- 207,268 ----
        if (r->method_number != M_GET) return NOT_IMPLEMENTED;
        r->content_type = "text/html";
    
  !     /*
  !      * Simple table-driven form data set parser that lets you alter the 
header
  !      */
  ! 
  !     if (r->args)
  !     {
  !     i = 0;
  !         while (options[i].id != STAT_OPT_END)
  !         {
  !             if ((loc = strstr(r->args,options[i].form_data_str)) != NULL)
  !         {
  !                 switch (options[i].id)
  !                 {
  !                   case STAT_OPT_REFRESH:
  !                       if(*(loc + strlen(options[i].form_data_str)) == '=')
  !                           table_set(r->headers_out,options[i].hdr_out_str,
  !                         loc+strlen(options[i].hdr_out_str)+1);
  !                       else
  !                           
table_set(r->headers_out,options[i].hdr_out_str,"1");
  !                       break;
  !                   case STAT_OPT_NOTABLE:
  !                       no_table_report = 1;
  !                       break;
  !                   case STAT_OPT_AUTO:
  !                       r->content_type = "text/plain";
  !                       short_report = 1;
  !                       break;
  !                 }
  !         }
  !         i++;
  !         }
        }
  + 
        soft_timeout ("send status info", r);
        send_http_header(r);
    
        if (r->header_only) 
        return 0;
    
        sync_scoreboard_image();
  !     for (i = 0; i<HARD_SERVER_MAX; ++i)
  !     {
            score_record = get_scoreboard_info(i);
            res = score_record.status;
  !     stat_buffer[i] = status[res];
            if (res == SERVER_READY)
            ready++;
            else if (res == SERVER_BUSY_READ || res==SERVER_BUSY_WRITE || 
                 res == SERVER_STARTING)
            busy++;
    #if defined(STATUS)
            lres = score_record.access_count;
        bytes= score_record.bytes_served;
  !         if (lres!=0 || (score_record.status != SERVER_READY
  !       && score_record.status != SERVER_DEAD))
  !     {
            tu+=score_record.times.tms_utime;
            ts+=score_record.times.tms_stime;
            tcu+=score_record.times.tms_cutime;
  ***************
  *** 275,353 ****
                count+=lres;
            bcount+=bytes;
        }
        }
  !     if (short_report) {
            sprintf(buffer,"Total Accesses: %lu\nTotal Bytes: 
%lu\n",count,bcount);
        rputs(buffer,r);
  !     } else {
  !         sprintf(buffer,"<p>Total accesses: %lu u%g s%g cu%g cs%g (",
  !             count,tu/tick,ts/tick,tcu/tick,tcs/tick);
  !     rputs(buffer,r);
  !     format_byte_out(r,bcount);
  !     rputs(")",r);
  !     }
  !     if (!short_report) {
  !         rputs("<hr><h2>Averages</h2>",r);
  !     if (up_time>0) {
  !         sprintf(buffer,"%.3g request per second<br>\n",
  !                 (float)count/(float)up_time);
  !         rputs(buffer,r);
  !     }
  !     if (up_time>0) {
  !         format_byte_out(r,(float)bcount/(float)up_time);
  !         rputs(" per second<br>\n",r);
  !     }
  !     if (count>0)  {
  !         format_byte_out(r,(float)bcount/(float)count);
  !         rputs(" per request<br>\n",r);
  !     }
        if(ts || tu || tcu || tcs)
  !         {
  !         sprintf(buffer,"%.3g%% CPU 
load<br>\n",(tu+ts+tcu+tcs)/tick/up_time*100.);
            rputs(buffer,r);
  !         }
  !     } else {
        sprintf(buffer,"Uptime: %ld\n",(long)(up_time));
        rputs(buffer,r);
  !     if (up_time>0) { 
            sprintf(buffer,"ReqPerSec: %g\n",
                    (float)count/(float)up_time);
            rputs(buffer,r);
        }
  !     if (up_time>0) {
            sprintf(buffer,"BytesPerSec: %g\n",
                (float)bcount/(float)up_time);
            rputs(buffer,r);
        }
  !     if (count>0) {
            sprintf(buffer,"BytesPerReq: %g\n",
                (float)bcount/(float)count);
            rputs(buffer,r);
        }
        if(ts || tu || tcu || tcs)
  !         {
  !         sprintf(buffer,"CPULoad: %g\n",(tu+ts+tcu+tcs)/tick/up_time*100.);
            rputs(buffer,r);
  !         }
        }
  ! #else
  !     rputs("<hr>To obtain a full report with current status information ",r);
  !     rputs("you need to recompile Apache adding the <code>-DSTATUS</code> 
",r);
  !     rputs("directive on the <code>CFLAGS</code> line in the ",r);
  !     rputs("<code>Configuration</code> file.",r);
  ! #endif
        if (!short_report)
            rputs("</body></html>",r);
        return 0;
    }
    
  ! handler_rec status_handlers[] = {
    { STATUS_MAGIC_TYPE, status_handler },
    { "server-status", status_handler },
    { NULL }
    };
    
  ! module status_module = {
       STANDARD_MODULE_STUFF,
       NULL,                    /* initializer */
       NULL,                    /* dir config creater */
  --- 270,546 ----
                count+=lres;
            bcount+=bytes;
        }
  + #endif /* STATUS */
        }
  ! 
  !     up_time=nowtime-restart_time;
  ! 
  !     if (!short_report)
  !     {
  !         rputs("<html><head><title>Apache Status</title></head><body>\n",r);
  !         rputs("<h1>Apache Server Status for ",r);
  !     rvputs(r,server->server_hostname,"</h1>\n\n",NULL);
  !     rvputs(r,"Current Time: ",asctime(localtime(&nowtime)),"<br>\n",NULL);
  !     rvputs(r,"Restart Time: ",asctime(localtime(&restart_time)),"<br>\n",
  !            NULL);
  !     rputs("Server uptime: ",r);
  !     show_time(r,up_time);
  !     rputs("<br>\n",r);
  !     }
  ! 
  ! #if defined(STATUS)
  !     if (short_report)
  !     {
            sprintf(buffer,"Total Accesses: %lu\nTotal Bytes: 
%lu\n",count,bcount);
        rputs(buffer,r);
  ! 
        if(ts || tu || tcu || tcs)
  !     {
  !         sprintf(buffer,"CPULoad: %g\n",(tu+ts+tcu+tcs)/tick/up_time*100.);
            rputs(buffer,r);
  !     }
  ! 
        sprintf(buffer,"Uptime: %ld\n",(long)(up_time));
        rputs(buffer,r);
  !     if (up_time>0)
  !     { 
            sprintf(buffer,"ReqPerSec: %g\n",
                    (float)count/(float)up_time);
            rputs(buffer,r);
        }
  ! 
  !     if (up_time>0)
  !     {
            sprintf(buffer,"BytesPerSec: %g\n",
                (float)bcount/(float)up_time);
            rputs(buffer,r);
        }
  ! 
  !     if (count>0)
  !     {
            sprintf(buffer,"BytesPerReq: %g\n",
                (float)bcount/(float)count);
            rputs(buffer,r);
        }
  +     } else /* !short_report */
  +     {
  +         sprintf(buffer,"Total accesses: %lu - Total Traffic: ", count);
  +     rputs(buffer,r);
  +     format_byte_out(r,bcount);
  +     rputs("<br>\n",r);
  +         sprintf(buffer,"CPU Usage: u%g s%g cu%g cs%g",
  +             tu/tick,ts/tick,tcu/tick,tcs/tick);
  +     rputs(buffer,r);
  + 
        if(ts || tu || tcu || tcs)
  !     {
  !         sprintf(buffer," - %.3g%% CPU load",
  !             (tu+ts+tcu+tcs)/tick/up_time*100.);
            rputs(buffer,r);
  !     }
  ! 
  !     rputs("<br>\n",r);
  ! 
  !     if (up_time>0)
  !     {
  !         sprintf(buffer,"%.3g requests/sec - ",
  !                 (float)count/(float)up_time);
  !         rputs(buffer,r);
  !     }
  ! 
  !     if (up_time>0)
  !     {
  !         format_byte_out(r,(float)bcount/(float)up_time);
  !         rputs("/second - ",r);
  !     }
  ! 
  !     if (count>0)
  !     {
  !         format_byte_out(r,(float)bcount/(float)count);
  !         rputs("/request",r);
  !     }
  ! 
  !     rputs("<p>\n",r);
  !     } /* short_report */
  ! #endif /* STATUS */
  ! 
  !     /* send the scoreboard 'table' out */
  ! 
  !     rputs("Scoreboard: \n",r);
  ! 
  !     if(!short_report)
  !     rputs("<PRE>",r);
  ! 
  !     rputs("\n",r);
  ! 
  !     for (i = 0; i<HARD_SERVER_MAX; ++i)
  !     {
  !     rputc(stat_buffer[i], r);
  !     if(i%STATUS_MAXLINE == (STATUS_MAXLINE - 1))
  !         rputs("\n",r);
  !     }
  ! 
  !     if (short_report)
  !     {
  !         sprintf(buffer,"\nBusyServers: %d\nIdleServers: %d\n",busy,ready);
  !     }
  !     else 
  !     {
  !     rputs("</PRE>\n",r);
  !     rputs("Key: \n",r);
  !     rputs("\"<code>_</code>\" Waiting for Connection, \n",r);
  !     rputs("\"<code>S</code>\" Starting up, \n",r);
  !     rputs("\"<code>R</code>\" Reading Request, \n",r);
  !     rputs("\"<code>W</code>\" Sending Reply<p>\n",r);
  !         sprintf(buffer,"\n%d requests currently being processed, %d idle 
servers\n",busy,ready);
  !     rputs(buffer,r);
  !     }
  ! 
  ! #if defined(STATUS)
  !     if (!short_report)
  !             if(no_table_report)
  !             rputs("<p><hr><h2>Server Details</h2>\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>B0<th>B1<th>B2<th>Host<th>Request</tr>\n\n",r);
  ! 
  ! 
  !     for (i = 0; i<HARD_SERVER_MAX; ++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;
  !     bytes= score_record.bytes_served;
  !     my_bytes = score_record.my_bytes_served;
  !     conn_bytes = score_record.conn_bytes;
  !         if (lres!=0 || (score_record.status != SERVER_READY
  !             && score_record.status != SERVER_DEAD))
  !     {
  !         if (!short_report)
  !         {
  !             if (no_table_report)
  !             {
  !                 sprintf(buffer,"<b>Server %d</b> (%d): %d|%lu|%lu [",
  !                  i,(int)score_record.pid,(int)conn_lres,my_lres,lres);
  !                 rputs(buffer,r);
  ! 
  !                 switch (score_record.status)
  !                 {
  !                     case SERVER_READY:
  !                         rputs("Ready",r);
  !                         break;
  !                     case SERVER_STARTING:
  !                         rputs("Starting",r);
  !                         break;
  !                     case SERVER_BUSY_READ:
  !                         rputs("<b>Read</b>",r);
  !                         break;
  !                     case SERVER_BUSY_WRITE:
  !                         rputs("<b>Write</b>",r);
  !                         break;
  !                     case SERVER_DEAD:
  !                         rputs("Dead",r);
  !                         break;
  !                 }
  !                 sprintf(buffer,"] 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,
  !                         asctime(localtime(&score_record.last_used)));
  !                 rputs(buffer,r);
  !                 format_byte_out(r,(unsigned long)conn_bytes);
  !                 rputs("|",r);
  !                 format_byte_out(r,my_bytes);
  !                 rputs("|",r);
  !                 format_byte_out(r,bytes);
  !                 rputs(")\n",r);
  !                 sprintf(buffer," <i>%s {%s}</i><br>\n\n",
  !                     score_record.client, score_record.request);
  !                 rputs(buffer,r);
  !             }
  !             else /* !no_table_report */
  !             {
  !                 sprintf(buffer,"<tr><td><b>%d</b><td>%d<td>%d/%lu/%lu",
  !                  i,(int)score_record.pid,(int)conn_lres,my_lres,lres);
  !                 rputs(buffer,r);
  ! 
  !                 switch (score_record.status)
  !                 {
  !                     case SERVER_READY:
  !                         rputs("<td>_",r);
  !                         break;
  !                     case SERVER_STARTING:
  !                         rputs("<td><b>S</b>",r);
  !                         break;
  !                     case SERVER_BUSY_READ:
  !                         rputs("<td><b>R</b>",r);
  !                         break;
  !                     case SERVER_BUSY_WRITE:
  !                         rputs("<td><b>W</b>",r);
  !                         break;
  !                     case SERVER_DEAD:
  !                         rputs("<td>.",r);
  !                         break;
  !                 }
  !                 sprintf(buffer,"\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,
  !                         difftime(nowtime, score_record.last_used));
  !                 rputs(buffer,r);
  !                 sprintf(buffer,"<td>%-1.1f<td>%-2.2f<td>%-2.2f\n",
  !                     (float)conn_bytes/KBYTE, (float)my_bytes/MBYTE,
  !                     (float)bytes/MBYTE);
  !                 rputs(buffer,r);
  !                 sprintf(buffer,"<td>%s<td>%s</tr>\n\n",
  !                     score_record.client, score_record.request);
  !                 rputs(buffer,r);
  !             }       /* no_table_report */
  !         }           /* !short_report */
  !     }               /* if (<active child>) */
  !     }                       /* for () */
  ! 
  !     if (!(short_report || no_table_report))
  !     {
  !     rputs("</table>\n \
  ! <ul>\n \
  !   <li>SRV = \"Server number\"\n \
  !   <li>PID = \"OS process ID\"\n \
  !   <li>Acc = \"Number of accesses this connection / this child / this 
slot\"\n \
  !   <li>M = \"Mode of operation\"\n \
  !   <li>CPU = \"CPU usage, number of seconds\"\n \
  !   <li>SS = \"Seconds since beginning of most recent request\"\n \
  !   <li>B0 = \"Kilobytes transferred this connection\"\n \
  !   <li>B1 = \"Megabytes transferred this child\"\n \
  !   <li>B2 = \"Total megabytes transferred this slot\"\n \
  ! </ul>\n",r);
        }
  ! 
  ! #else /* !defined(STATUS) */
  ! 
  !     rputs("<hr>To obtain a full report with current status information 
\n",r);
  !     rputs("you need to recompile Apache adding the <code>-DSTATUS</code> 
\n",r);
  !     rputs("directive on the <code>CFLAGS</code> line in the \n",r);
  !     rputs("<code>Configuration</code> file.\n",r);
  ! 
  ! #endif /* STATUS */
  ! 
        if (!short_report)
            rputs("</body></html>",r);
        return 0;
    }
    
  ! handler_rec status_handlers[] =
  ! {
    { STATUS_MAGIC_TYPE, status_handler },
    { "server-status", status_handler },
    { NULL }
    };
    
  ! module status_module =
  ! {
       STANDARD_MODULE_STUFF,
       NULL,                    /* initializer */
       NULL,                    /* dir config creater */
  
  
  
  1.9       +2 -0      apache/src/scoreboard.h
  
  Index: scoreboard.h
  ===================================================================
  RCS file: /export/home/cvs/apache/src/scoreboard.h,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -C3 -r1.8 -r1.9
  *** scoreboard.h      1996/04/09 08:18:37     1.8
  --- scoreboard.h      1996/05/07 18:29:35     1.9
  ***************
  *** 77,82 ****
  --- 77,84 ----
        unsigned long bytes_served;
        unsigned long my_access_count;
        unsigned long my_bytes_served;
  +     unsigned short conn_count;
  +     unsigned short conn_bytes;
        struct tms times;
        time_t last_used;
        char client[32];        /* Keep 'em small... */
  
  
  

Reply via email to