much better output for /proc/$pid/status
authorDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 30 Jul 2009 22:55:08 +0000 (22:55 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 30 Jul 2009 22:55:08 +0000 (22:55 +0000)
lib/PXElator/httpd.pm

index e6c5dde..035053f 100644 (file)
@@ -143,15 +143,24 @@ sub get_request {
                        'debug',        qq|<a href=/our/debug/| . boolean::toggle($debug) . qq|>$debug</a>|,
                );
 
+               my $debug_proc;
+
                warn 'pids: ', dump( $pids );
                foreach my $name ( keys %$pids ) {
                        my $pid = $pids->{$name} || next;
-                       my $proc = "/proc/$pid/status";
 
                        my $html = qq|<a href=/$name>$pid</a>|;
-                       $html   .= qq|<pre style="font-size: 10%">|
-                                       .  ( $debug && -e $proc ? read_file($proc) : '' )
-                                       .  qq|</pre>| if $debug;
+
+                       if ( $debug ) {
+                               $html .= qq| <a name=$pid href=#proc-$pid>?</a>|;
+
+                               my $proc = "/proc/$pid/status";
+                               $debug_proc
+                                       .= qq|<a name=proc-$pid href=#$pid>$proc</a><pre style="font-size: 10%">|
+                                       .  read_file($proc)
+                                       .  qq|</pre>|
+                                       if -e $proc;
+                       }
 
                        push @rows, ( $name => $html );
                }
@@ -166,7 +175,7 @@ sub get_request {
                        }
                }
 
-               print $client $ok, html::table( 2, @rows );
+               print $client $ok, html::table( 2, @rows ), $debug_proc;
 
        } elsif ( $path =~ m{^/our/(\w+)/(\S+)} ) {
                eval 'our $' . $1 . ' = ' . $2;