You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ji...@apache.org on 2012/12/05 18:07:51 UTC

svn commit: r1417529 - /httpd/httpd/trunk/modules/generators/mod_status.c

Author: jim
Date: Wed Dec  5 17:07:50 2012
New Revision: 1417529

URL: http://svn.apache.org/viewvc?rev=1417529&view=rev
Log:
Add useful mod_status info... try to determine last time
a specific vhost was accessed/used.

Modified:
    httpd/httpd/trunk/modules/generators/mod_status.c

Modified: httpd/httpd/trunk/modules/generators/mod_status.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/generators/mod_status.c?rev=1417529&r1=1417528&r2=1417529&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/generators/mod_status.c (original)
+++ httpd/httpd/trunk/modules/generators/mod_status.c Wed Dec  5 17:07:50 2012
@@ -619,6 +619,7 @@ static int status_handler(request_rec *r
     }
 
     if (ap_extended_status && !short_report) {
+        apr_table_t *vhosts = apr_table_make(r->pool, 10);
         if (no_table_report)
             ap_rputs("<hr /><h2>Server Details</h2>\n\n", r);
         else
@@ -635,6 +636,10 @@ static int status_handler(request_rec *r
 
         for (i = 0; i < server_limit; ++i) {
             for (j = 0; j < thread_limit; ++j) {
+                char *escvhost;
+                long last_used;
+                const char *vlast;
+
                 ws_record = ap_get_scoreboard_worker_from_indexes(i, j);
 
                 if (ws_record->access_count == 0 &&
@@ -654,6 +659,22 @@ static int status_handler(request_rec *r
                 if (req_time < 0L)
                     req_time = 0L;
 
+                escvhost = ap_escape_html(r->pool, ws_record->vhost);
+                last_used = (long)apr_time_sec(nowtime - ws_record->last_used);
+                if (escvhost && *escvhost) {
+                    if ((vlast = apr_table_get(vhosts, escvhost)) != NULL) {
+                        long temp = atol(vlast);
+                        if (last_used < temp) {
+                            apr_table_setn(vhosts, apr_pstrdup(r->pool, escvhost),
+                                           apr_psprintf(r->pool, "%ld", last_used));
+                        }
+                    }
+                    else {
+                        apr_table_setn(vhosts, apr_pstrdup(r->pool, escvhost),
+                                           apr_psprintf(r->pool, "%ld", last_used));
+                    }
+                }
+
                 lres = ws_record->access_count;
                 my_lres = ws_record->my_access_count;
                 conn_lres = ws_record->conn_count;
@@ -733,8 +754,7 @@ static int status_handler(request_rec *r
                                ws_record->times.tms_cutime / tick,
                                ws_record->times.tms_cstime / tick,
 #endif
-                               (long)apr_time_sec(nowtime -
-                                                  ws_record->last_used),
+                               last_used,
                                (long) req_time);
 
                     format_byte_out(r, conn_bytes);
@@ -750,8 +770,7 @@ static int status_handler(request_rec *r
                                ap_escape_html(r->pool,
                                               ap_escape_logitem(r->pool,
                                                                 ws_record->request)),
-                               ap_escape_html(r->pool,
-                                              ws_record->vhost));
+                               escvhost);
                 }
                 else { /* !no_table_report */
                     if (ws_record->status == SERVER_DEAD)
@@ -820,8 +839,7 @@ static int status_handler(request_rec *r
                                 ws_record->times.tms_cutime +
                                 ws_record->times.tms_cstime) / tick,
 #endif
-                               (long)apr_time_sec(nowtime -
-                                                  ws_record->last_used),
+                               last_used,
                                (long)req_time);
 
                     ap_rprintf(r, "</td><td>%-1.1f</td><td>%-2.2f</td><td>%-2.2f\n",
@@ -832,8 +850,7 @@ static int status_handler(request_rec *r
                                   "<td nowrap>%s</td></tr>\n\n",
                                ap_escape_html(r->pool,
                                               ws_record->client),
-                               ap_escape_html(r->pool,
-                                              ws_record->vhost),
+                               escvhost,
                                ap_escape_html(r->pool,
                                               ap_escape_logitem(r->pool,
                                                       ws_record->request)));
@@ -842,6 +859,10 @@ static int status_handler(request_rec *r
         } /* for (i...) */
 
         if (!no_table_report) {
+            int i;
+            const apr_array_header_t *arr = apr_table_elts(vhosts);
+            const apr_table_entry_t *elts = (const apr_table_entry_t *)arr->elts;
+
             ap_rputs("</table>\n \
 <hr /> \
 <table>\n \
@@ -860,6 +881,13 @@ static int status_handler(request_rec *r
 <tr><th>Child</th><td>Megabytes transferred this child</td></tr>\n \
 <tr><th>Slot</th><td>Total megabytes transferred this slot</td></tr>\n \
 </table>\n", r);
+            ap_rputs("<hr />\n<table>\n\
+<tr><th>Vhost</th><th>Seconds since last used</th></tr>\n", r);
+            for (i = 0; i < arr->nelts; i++) {
+                ap_rprintf(r, "<tr><td><pre>%s</pre></td><td><pre>%27s</pre></td></tr>\n",
+                           elts[i].key, elts[i].val);
+            }
+            ap_rputs("</table>\n", r);
         }
     } /* if (ap_extended_status && !short_report) */
     else {