[padb] r414 committed - Better error checking in the proc-summary mode....

padb at googlecode.com padb at googlecode.com
Mon Nov 8 18:27:44 GMT 2010


Revision: 414
Author: apittman at gmail.com
Date: Mon Nov  8 10:27:13 2010
Log: Better error checking in the proc-summary mode.
If selecting samples which are quick to measure the elapsed time
during this might be zero, if this is the case then don't attempt
to use this value for division or bad things will happen.
Ideally if any of these stats are being reported padb should
sample them, wait and then sample them again but right now it
doesn't do the wait and the two samples can happen in apparantly
zero time.

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

Modified:
  /trunk/src/padb

=======================================
--- /trunk/src/padb	Mon Nov  8 10:23:03 2010
+++ /trunk/src/padb	Mon Nov  8 10:27:13 2010
@@ -3996,7 +3996,8 @@
              my $value = $lines->{$tag}{$key};
              next unless defined $proc_format_lengths{$key} or $show_fields;

-            if ( length $value > $proc_format_lengths{$key} ) {
+            if ( defined $value and length $value >  
$proc_format_lengths{$key} )
+            {
                  $proc_format_lengths{$key} = length $value;
              }

@@ -8338,27 +8339,29 @@

              next unless defined $proc->{stat_end};

-            proc_output(
-                $vp, 'pcpu',
-                pcpu_total(
-                    $cpucount,           $elapsed,
-                    $proc->{stat_start}, $proc->{stat_end}
-                )
-            );
-            proc_output(
-                $vp, 'pucpu',
-                pcpu_user(
-                    $cpucount,           $elapsed,
-                    $proc->{stat_start}, $proc->{stat_end}
-                )
-            );
-            proc_output(
-                $vp, 'pscpu',
-                pcpu_sys(
-                    $cpucount,           $elapsed,
-                    $proc->{stat_start}, $proc->{stat_end}
-                )
-            );
+            if ( $elapsed > 0 ) {
+                proc_output(
+                    $vp, 'pcpu',
+                    pcpu_total(
+                        $cpucount,           $elapsed,
+                        $proc->{stat_start}, $proc->{stat_end}
+                    )
+                );
+                proc_output(
+                    $vp, 'pucpu',
+                    pcpu_user(
+                        $cpucount,           $elapsed,
+                        $proc->{stat_start}, $proc->{stat_end}
+                    )
+                );
+                proc_output(
+                    $vp, 'pscpu',
+                    pcpu_sys(
+                        $cpucount,           $elapsed,
+                        $proc->{stat_start}, $proc->{stat_end}
+                    )
+                );
+            }
          }
      }





More information about the padb-devel mailing list