Replying to myself:

> (This problem is another argument for having a handler to display the
> contents of the child_info_table. I'll try to find some free time in
> order to code one).

I had a look at mod_status and noticed that it already has a nice
extension hook. I extended peruser to register this hook and to dump its
child_info table when the status is requested. Please find the patch
attached to this email. You should compile and enable mod_status as
usual (don't forget to set ExtendedStatus to "on"). If you call your
/server-status handler as usual you should notice a new section at the
end of the output which will look like this:

> ID    PID     STATUS  TYPE            UID     GID     CHROOT  INPUT   OUTPUT  
> SOCK_FD TOTAL P MAX P   IDLE P  MIN FREE PROCESSORS
> 0     30450   ACTIVE  MULTIPLEXER     65534   65534   (null)  11      12      
> -1      1       10      1       2
> 1     30451   ACTIVE  PROCESSOR       1002    407     (null)  13      14      
> -1      4       20      3       4
> 2     30455   ACTIVE  PROCESSOR       1003    408     (null)  17      18      
> -1      4       20      4       4
> 3     30452   ACTIVE  WORKER          1002    407     (null)  13      14      
> -1      4       20      3       4
> 4     30453   ACTIVE  WORKER          1002    407     (null)  13      14      
> -1      4       20      3       4
> 5     30454   ACTIVE  WORKER          1002    407     (null)  13      14      
> -1      4       20      3       4
> 6     30456   ACTIVE  WORKER          1003    408     (null)  17      18      
> -1      4       20      4       4
> 7     30457   ACTIVE  WORKER          1003    408     (null)  17      18      
> -1      4       20      4       4
> 8     30458   ACTIVE  WORKER          1003    408     (null)  17      18      
> -1      4       20      4       4

I hope that people will find this useful in monitoring/debugging peruser.

Janno: Can you try to figure out what's going on using this patch? The
stuff in your last emails was pretty hard to analyze because of all the
word wrapping. If you cannot teach your email client to leave the lines
intact then an attachment/url might be the better choice.

Sean: It looks like a lot of nice patches and fixes are floating around
right now. Can you please try to wrap them up in a new release? At the
moment everybody seems to have different patches applied which makes
sorting out stuff really ugly. Call it "beta" or something like that if
you feel that it is not stable enough for a release.

Stefan




--- peruser.c.without-status    2007-01-30 20:40:38.000000000 +0100
+++ peruser.c   2007-01-30 21:25:17.000000000 +0100
@@ -98,6 +98,7 @@
 #include "ap_mmn.h"
 #include "apr_poll.h"
 #include "util_ebcdic.h"
+#include "mod_status.h"
 
 #ifdef HAVE_BSTRING_H
 #include <bstring.h>           /* for IRIX, FD_SET calls bzero() */
@@ -2655,6 +2656,49 @@
     return OK;
 }
 
+static int peruser_status_hook(request_rec *r, int flags)
+{
+    int x;
+    server_env_t *senv;
+
+    if (flags & AP_STATUS_SHORT)
+           return OK;
+    
+    ap_rputs("<hr>\n", r);
+    ap_rputs("<h2>peruser status</h2>\n", r);
+    ap_rputs("<table border=\"0\">\n", r);
+    
ap_rputs("<tr><td>ID</td><td>PID</td><td>STATUS</td><td>TYPE</td><td>UID</td>"
+                   "<td>GID</td><td>CHROOT</td><td>INPUT</td>"
+                   "<td>OUTPUT</td><td>SOCK_FD</td>"
+                   "<td>TOTAL PROCESSORS</td><td>MAX PROCESSORS</td>"
+                   "<td>IDLE PROCESSORS</td><td>MIN FREE 
PROCESSORS</td></tr>\n", r);
+    for (x = 0; x < NUM_CHILDS; x++)
+        {
+        senv = CHILD_INFO_TABLE[x].senv;
+        ap_rprintf(r, "<tr><td>%3d</td><td>%5d</td><td>%8s</td><td>%12s</td>"
+                       "<td>%4d</td><td>%4d</td><td>%25s</td><td>%5d</td>"
+                       "<td>%6d</td><td>%7d</td><td>%d</td><td>%d</td>"
+                       "<td>%d</td><td>%d</td></tr>\n", 
+                       CHILD_INFO_TABLE[x].id, 
+                       CHILD_INFO_TABLE[x].pid, 
+                       child_status_string(CHILD_INFO_TABLE[x].status), 
+                       child_type_string(CHILD_INFO_TABLE[x].type), 
+                       senv == NULL ? -1 : senv->uid, 
+                       senv == NULL ? -1 : senv->gid, 
+                       senv == NULL ? NULL : senv->chroot, 
+                       senv == NULL ? -1 : CHILD_INFO_TABLE[x].senv->input, 
+                       senv == NULL ? -1 : CHILD_INFO_TABLE[x].senv->output, 
+                       CHILD_INFO_TABLE[x].sock_fd,
+                       total_processors(x), 
+                       senv == NULL ? -1 : 
CHILD_INFO_TABLE[x].senv->max_processors,
+                       idle_processors(x),
+                       senv == NULL ? -1 : 
CHILD_INFO_TABLE[x].senv->min_free_processors
+                       );
+       }
+    ap_rputs("</table>\n", r);
+    return OK;
+}
+
 static void peruser_hooks(apr_pool_t *p)
 {
     /* The peruser open_logs phase must run before the core's, or stderr
@@ -2682,6 +2726,8 @@
                               APR_HOOK_REALLY_FIRST);
     ap_hook_process_connection(peruser_process_connection, NULL, NULL,
                                APR_HOOK_REALLY_FIRST);
+
+    APR_OPTIONAL_HOOK(ap, status_hook, peruser_status_hook, NULL, NULL, 
APR_HOOK_MIDDLE);
 }
 
 /* we define an Processor w/ specific uid/gid */
_______________________________________________
Peruser mailing list
[email protected]
http://www.telana.com/mailman/listinfo/peruser

Reply via email to