[padb] r356 committed - Refresh the lstopo mode and add a generic "command" mode....

padb at googlecode.com padb at googlecode.com
Wed Dec 9 17:51:33 GMT 2009


Revision: 356
Author: apittman
Date: Wed Dec  9 09:51:13 2009
Log: Refresh the lstopo mode and add a generic "command" mode.
Change the lstopo command to add a dash '-' which tells it to give
text based output rather than graphical, also extend this mode to
allow the precise lstopo command to be specified as an option.  The
command given is exected on the target node and %p is replaced with
the pid of the target process.  This should future proof padb as when
a --pid option gets added to lstopo padb will be able to use it by
just editing a configuration file rather than editing the code.

Also add a generic "command" mode which will run any command, again
substituting %p with the pid of the target process, this is in effect
what lstopo is now so add a mode to do this specifically othewise I'm
sure people would try and piggy-back this behaviour onto the lstopo
mode.  The default command is 'readlink /proc/%p/exe'.

http://code.google.com/p/padb/source/detail?r=356

Modified:
  /trunk/src/padb

=======================================
--- /trunk/src/padb	Wed Dec  9 03:07:11 2009
+++ /trunk/src/padb	Wed Dec  9 09:51:13 2009
@@ -7957,17 +7957,23 @@
      return;
  }

-# Experimental, currently reports on what's on the node rather than what
-# the specific process is attached to, hopefully this functionality will be
-# added in the future.
+# Experimental, currently reports on what's on the node rather than
+# what the specific process is attached to, hopefully this
+# functionality will be added in the future.

  # https://svn.open-mpi.org/trac/hwloc/ticket/21
  sub lstopo {
      my ( $cargs, $vp, $pid ) = @_;

-    target_error( $vp, "Reporting per node rather than per process" );
-
-    my @output = slurp_cmd("lstopo --whole-system");
+    if ( $cargs->{lstopo_show_warning} ) {
+        target_error( $vp, "Reporting per node rather than per process" );
+    }
+
+    my $cmd = $cargs->{lstopo_command};
+
+    $cmd =~ s{%p}{$pid}g;
+
+    my @output = slurp_cmd($cmd);

      # Check the return code, if it's not found then there won't be any
      # output, if it was found but returned an error then do report the
@@ -7988,6 +7994,21 @@
      }
      return;
  }
+
+sub run_cmd_against_target {
+    my ( $cargs, $vp, $pid ) = @_;
+
+    my $cmd = $cargs->{command};
+
+    $cmd =~ s{%p}{$pid}g;
+
+    my @output = slurp_cmd($cmd);
+    chomp @output;
+    foreach my $line (@output) {
+        output( $vp, $line );
+    }
+    return;
+}

  sub ping_rank {
      my ( $cargs, $vp, $pid ) = @_;
@@ -9351,9 +9372,18 @@
      };

      $allfns{lstopo} = {
-        handler  => \&lstopo,
-        arg_long => 'lstopo',
-        help     => 'Show CPU topology',
+        handler      => \&lstopo,
+        arg_long     => 'lstopo',
+        help         => 'Show CPU topology using lstopo',
+        options_i    => { lstopo_command => 'lstopo --whole-system -', },
+        options_bool => { lstopo_show_warning => 'yes', },
+    };
+
+    $allfns{command} = {
+        handler   => \&run_cmd_against_target,
+        arg_long  => 'command',
+        help      => 'Run command on target node',
+        options_i => { command => 'readlink /proc/%p/exe', }
      };

      $allfns{ping} = {




More information about the padb-devel mailing list