Whamcloud - gitweb
land v0.9.1 on HEAD, in preparation for a 1.0.x branch
[fs/lustre-release.git] / lustre / utils / llanalyze
index 56e58c8..97c691a 100644 (file)
@@ -11,7 +11,6 @@ GetOptions("pid=i" => \$pid,
            "noclass!" => \$noclass,
            "nonet!" => \$nonet);
 
-print "pid: $pid, nodlm $nodlm nonet $nonet trace $trace\n";
 
 
 $subsys->{UNDEFINED} = 0;
@@ -35,6 +34,8 @@ $subsys->{LDLM} = 17;
 $subsys->{LOV} = 18;
 $subsys->{GMNAL} = 19;
 $subsys->{PTLROUTER} = 20;
+$subsys->{COBD} = 21;
+$subsys->{IBNAL} = 22;
 
 
 $masks->{TRACE} = 1 << 0; # /* ENTRY/EXIT markers */
@@ -63,11 +64,8 @@ sub extractpid
 {
     $line = shift;
 #    print "$_\n";
-    if ($line =~ m/\(\) ([0-9]*)\+[0-9]*\):/) {
-       return $1;
-    }
-    if ($line =~ m/\(\) ([0-9]*) \| [0-9]*\+[0-9]*\):/) {
-       return $1;
+    if ($line =~ m/\d+:\d+:\d+:\d+\.\d+:\d+:\d+:*$/) {
+       return $6;
     }
 }
 
@@ -75,11 +73,32 @@ sub extracthostpid
 {
     $line = shift;
 #    print "$_\n";
-    if ($line =~ m/\(\) [0-9]* \| ([0-9]*)\+[0-9]*\):/) {
-       return $1;
+    if ($line =~ m/\d+:\d+:\d+:\d+\.\d+:\d+:\d+:\d+:*$/) {
+       return $7;
     }
 }
 
+sub entering_rpc
+{
+       $_ = shift;
+       $entering_rpc  = /Handling RPC/;
+       if($entering_rpc) {
+               $oldpid=$pid;
+               $pid = extractpid($_);
+               $leaving_rpc = 0;
+       }
+}
+
+sub leaving_rpc
+{
+       $_ = shift;
+       $leaving_rpc  = /Handled RPC/;
+       if($leaving_rpc) {
+               $pid = $oldpid; 
+               $entering_rpc = 0;
+       }
+}
+
 sub entering
 {
     $_ = shift;
@@ -107,8 +126,13 @@ sub getmask
 sub setcolor
 {
     my $linemask = shift;
+    my $line = shift;
     if ($linemask == $masks->{TRACE}) {
-        print color("yellow on_black");
+        if(leaving($line)){
+           print color("yellow on_black");
+        } else {
+           print color("green on_black");
+        }
     }
     if ($linemask == $masks->{DLMTRACE}) {
         print color("magenta on_black");
@@ -220,7 +244,27 @@ sub unmatched_intents {
     }
 }
 
-while (<STDIN>) {
+sub usage
+{
+   print "Usage : llanalyze LOGFILE\n";
+   exit;
+}
+
+if ($ARGV[0]) {
+    if(!open(LOG, "<$ARGV[0]")){
+      print "Cannot open $ARGV[0]\n";
+      exit;
+    }
+} else {
+    usage();
+}
+$width = 0;
+if ($ARGV[1]) {
+   $width = $ARGV[1];
+}
+
+print "pid: $pid, nodlm $nodlm nonet $nonet trace $trace\n";
+while (<LOG>) {
     $linepid = extractpid($_);
     $linehpid = extracthostpid($_);
     $linemask = getmask($_);
@@ -241,7 +285,7 @@ while (<STDIN>) {
     }
 
     if ( !$pid || $linepid == $pid || $linehpid == $pid) {
-        next if ($rpctrace && $linemask != $masks->{RPCTRACE});
+        next if (!$entering_rpc && $rpctrace && $linemask != $masks->{RPCTRACE});
         next if ($trace && $linemask != $masks->{TRACE});
 
 
@@ -256,13 +300,19 @@ while (<STDIN>) {
                     $linesubsys == $subsys->{PORTALS} ||
                     $linesubsys == $subsys->{SOCKNAL} ||
                     $linesubsys == $subsys->{QSWNAL} ||
+                    $linesubsys == $subsys->{IBNAL} ||
                     $linesubsys == $subsys->{GMNAL}));
-
+       if(!$entering_rpc) {entering_rpc($_);}
+       if(!$leaving_rpc) {leaving_rpc($_);}
 
 #        printf "sub/mask: %s - %s\n", getsubsys($_), getmask($_);
-        if (!$silent) { 
-            setcolor($linemask);
-            printf("%s%s", $prefix->{$linepid}, $_);
+        if (!$silent) {
+            setcolor($linemask, $_);
+            my $string = $prefix->{$linepid}.$_;
+            if($width){ 
+               $string = substr($string, 0, $width)."\n";
+            }
+            printf("%s", $string);
             print color("reset");
         }
             #        last if $count++ > 100;