r32135 - in /trunk/libsys-statistics-linux-perl: ./ debian/ lib/Sys/Statistics/ lib/Sys/Statistics/Linux/ t/

ryan52-guest at users.alioth.debian.org ryan52-guest at users.alioth.debian.org
Mon Mar 16 01:06:42 UTC 2009


Author: ryan52-guest
Date: Mon Mar 16 01:06:38 2009
New Revision: 32135

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=32135
Log:
New upstream release

Modified:
    trunk/libsys-statistics-linux-perl/ChangeLog
    trunk/libsys-statistics-linux-perl/META.yml
    trunk/libsys-statistics-linux-perl/README
    trunk/libsys-statistics-linux-perl/debian/changelog
    trunk/libsys-statistics-linux-perl/lib/Sys/Statistics/Linux.pm
    trunk/libsys-statistics-linux-perl/lib/Sys/Statistics/Linux/CpuStats.pm
    trunk/libsys-statistics-linux-perl/lib/Sys/Statistics/Linux/DiskStats.pm
    trunk/libsys-statistics-linux-perl/lib/Sys/Statistics/Linux/NetStats.pm
    trunk/libsys-statistics-linux-perl/lib/Sys/Statistics/Linux/PgSwStats.pm
    trunk/libsys-statistics-linux-perl/lib/Sys/Statistics/Linux/ProcStats.pm
    trunk/libsys-statistics-linux-perl/lib/Sys/Statistics/Linux/Processes.pm
    trunk/libsys-statistics-linux-perl/t/050-pgswstats.t
    trunk/libsys-statistics-linux-perl/t/070-sockstats.t
    trunk/libsys-statistics-linux-perl/t/080-diskstats.t
    trunk/libsys-statistics-linux-perl/t/120-processes.t
    trunk/libsys-statistics-linux-perl/t/130-search.t
    trunk/libsys-statistics-linux-perl/t/140-psfind.t
    trunk/libsys-statistics-linux-perl/t/150-pstop.t

Modified: trunk/libsys-statistics-linux-perl/ChangeLog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libsys-statistics-linux-perl/ChangeLog?rev=32135&op=diff
==============================================================================
--- trunk/libsys-statistics-linux-perl/ChangeLog (original)
+++ trunk/libsys-statistics-linux-perl/ChangeLog Mon Mar 16 01:06:38 2009
@@ -1,3 +1,15 @@
+0.49    Released at 2009-03-15.
+        - Just a full version... all tests runs without errors.
+
+0.48_02 Released at 2009-03-11.
+        - Fixed some tests and updated the documentation.
+
+0.48_01 Released at 2009-03-07.
+        - Fixed some tests.
+        - Fixed initfile in CpuStats, DiskStats, NetStats, PgSwStats and
+          ProcStats - if the machine was rebootet the deltas couldn't be
+          calculated.
+
 0.48    Released at 2009-03-07.
         - Fixed tests 050-pgswstats.t, 070-sockstats.t, 080-diskstats.t.
           If linux runs as a virtual machine than it's possible that the

Modified: trunk/libsys-statistics-linux-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libsys-statistics-linux-perl/META.yml?rev=32135&op=diff
==============================================================================
--- trunk/libsys-statistics-linux-perl/META.yml (original)
+++ trunk/libsys-statistics-linux-perl/META.yml Mon Mar 16 01:06:38 2009
@@ -1,6 +1,6 @@
 ---
 name: Sys-Statistics-Linux
-version: 0.48
+version: 0.49
 author:
   - Jonny Schulz
 abstract: Front-end module to collect system statistics
@@ -18,16 +18,16 @@
 provides:
   Sys::Statistics::Linux:
     file: lib/Sys/Statistics/Linux.pm
-    version: 0.48
+    version: 0.49
   Sys::Statistics::Linux::Compilation:
     file: lib/Sys/Statistics/Linux/Compilation.pm
     version: 0.10
   Sys::Statistics::Linux::CpuStats:
     file: lib/Sys/Statistics/Linux/CpuStats.pm
-    version: 0.16
+    version: 0.17
   Sys::Statistics::Linux::DiskStats:
     file: lib/Sys/Statistics/Linux/DiskStats.pm
-    version: 0.20
+    version: 0.21
   Sys::Statistics::Linux::DiskUsage:
     file: lib/Sys/Statistics/Linux/DiskUsage.pm
     version: 0.10
@@ -42,16 +42,16 @@
     version: 0.14
   Sys::Statistics::Linux::NetStats:
     file: lib/Sys/Statistics/Linux/NetStats.pm
-    version: 0.16
+    version: 0.17
   Sys::Statistics::Linux::PgSwStats:
     file: lib/Sys/Statistics/Linux/PgSwStats.pm
-    version: 0.14
+    version: 0.15
   Sys::Statistics::Linux::ProcStats:
     file: lib/Sys/Statistics/Linux/ProcStats.pm
-    version: 0.15
+    version: 0.16
   Sys::Statistics::Linux::Processes:
     file: lib/Sys/Statistics/Linux/Processes.pm
-    version: 0.24
+    version: 0.25
   Sys::Statistics::Linux::SockStats:
     file: lib/Sys/Statistics/Linux/SockStats.pm
     version: 0.07

Modified: trunk/libsys-statistics-linux-perl/README
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libsys-statistics-linux-perl/README?rev=32135&op=diff
==============================================================================
--- trunk/libsys-statistics-linux-perl/README (original)
+++ trunk/libsys-statistics-linux-perl/README Mon Mar 16 01:06:38 2009
@@ -55,6 +55,19 @@
     me what's wrong and I will try to solve it! You just have to make the
     first move and to send me a mail. :-)
 
+VIRTUAL MACHINES
+    Note that if you try to install or run "Sys::Statistics::Linux" under
+    virtual machines on guest systems that some statistics are not
+    available, such as "SockStats", "PgSwStats" and "DiskStats". The reason
+    is that not all /proc data are passed to the guests.
+
+    If the installation fails then try to force the installation with
+
+        cpan> force install Sys::Statistics::Linux
+
+    and notice which tests fails, because this statistics maybe not
+    available on your system - sorry.
+
 DELTAS
     The statistics for "CpuStats", "ProcStats", "PgSwStats", "NetStats",
     "DiskStats" and "Processes" are deltas, for this reason it's necessary
@@ -97,7 +110,7 @@
         1 - activate and init statistics
         2 - activate statistics but don't init
 
-    In addition it's possible to pass a hash reference with optinos.
+    In addition it's possible to pass a hash reference with options.
 
         my $lxs = Sys::Statistics::Linux->new(
             processes => {
@@ -109,6 +122,65 @@
                 initfile => $file,
             },
         );
+
+    Option "initfile" is useful if you want to store initial statistics on
+    the filesystem.
+
+        my $lxs = Sys::Statistics::Linux->new(
+            cpustats => {
+                init     => 1,
+                initfile => '/tmp/cpustats.yml',
+            },
+            diskstats => {
+                init     => 1,
+                initfile => '/tmp/diskstats.yml',
+            },
+            netstats => {
+                init     => 1,
+                initfile => '/tmp/netstats.yml',
+            },
+            pgswttats => {
+                init     => 1,
+                initfile => '/tmp/pgswstats.yml',
+            },
+            procstats => {
+                init     => 1,
+                initfile => '/tmp/procstats.yml',
+            },
+        );
+
+    Example:
+
+        #!/usr/bin/perl
+        use strict;
+        use warnings;
+        use Sys::Statistics::Linux;
+
+        my $lxs = Sys::Statistics::Linux->new(
+            pgswstats => {
+                init => 1,
+                initfile => '/tmp/pgswstats.yml'
+            }
+        );
+
+        $lxs->get(); # without to sleep
+
+    The initial statistics are stored to the temporary file:
+
+        #> cat /tmp/pgswstats.yml
+        --- 
+        pgfault: 397040955
+        pgmajfault: 4611
+        pgpgin: 21531693
+        pgpgout: 49511043
+        pswpin: 8
+        pswpout: 272
+        time: 1236783534.9328
+
+    Every time you call the script the initial statistics are loaded/stored
+    from/to the file. This could be helpful if you doesn't run it as daemon
+    and if you want to calculate the average load of your system since the
+    last call. Do you understand? I hope so :)
 
     To get more informations about the statistics refer the different
     modules of the distribution.

Modified: trunk/libsys-statistics-linux-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libsys-statistics-linux-perl/debian/changelog?rev=32135&op=diff
==============================================================================
--- trunk/libsys-statistics-linux-perl/debian/changelog (original)
+++ trunk/libsys-statistics-linux-perl/debian/changelog Mon Mar 16 01:06:38 2009
@@ -1,3 +1,9 @@
+libsys-statistics-linux-perl (0.49-1) UNRELEASED; urgency=low
+
+  * New upstream release
+
+ -- Ryan Niebur <ryanryan52 at gmail.com>  Sun, 15 Mar 2009 18:06:23 -0700
+
 libsys-statistics-linux-perl (0.48-1) unstable; urgency=low
 
   [ Rene Mayorga ]

Modified: trunk/libsys-statistics-linux-perl/lib/Sys/Statistics/Linux.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libsys-statistics-linux-perl/lib/Sys/Statistics/Linux.pm?rev=32135&op=diff
==============================================================================
--- trunk/libsys-statistics-linux-perl/lib/Sys/Statistics/Linux.pm (original)
+++ trunk/libsys-statistics-linux-perl/lib/Sys/Statistics/Linux.pm Mon Mar 16 01:06:38 2009
@@ -53,6 +53,18 @@
 Don't give up if some of the modules doesn't run on your hardware! Tell me what's wrong
 and I will try to solve it! You just have to make the first move and to send me a mail. :-)
 
+=head1 VIRTUAL MACHINES
+
+Note that if you try to install or run C<Sys::Statistics::Linux> under virtual machines
+on guest systems that some statistics are not available, such as C<SockStats>, C<PgSwStats>
+and C<DiskStats>. The reason is that not all /proc data are passed to the guests.
+
+If the installation fails then try to force the installation with
+
+    cpan> force install Sys::Statistics::Linux
+
+and notice which tests fails, because this statistics maybe not available on your system - sorry.
+
 =head1 DELTAS
 
 The statistics for C<CpuStats>, C<ProcStats>, C<PgSwStats>, C<NetStats>, C<DiskStats> and C<Processes>
@@ -93,7 +105,7 @@
     1 - activate and init statistics
     2 - activate statistics but don't init
 
-In addition it's possible to pass a hash reference with optinos.
+In addition it's possible to pass a hash reference with options.
 
     my $lxs = Sys::Statistics::Linux->new(
         processes => {
@@ -105,6 +117,63 @@
             initfile => $file,
         },
     );
+
+Option C<initfile> is useful if you want to store initial statistics on the filesystem.
+
+    my $lxs = Sys::Statistics::Linux->new(
+        cpustats => {
+            init     => 1,
+            initfile => '/tmp/cpustats.yml',
+        },
+        diskstats => {
+            init     => 1,
+            initfile => '/tmp/diskstats.yml',
+        },
+        netstats => {
+            init     => 1,
+            initfile => '/tmp/netstats.yml',
+        },
+        pgswttats => {
+            init     => 1,
+            initfile => '/tmp/pgswstats.yml',
+        },
+        procstats => {
+            init     => 1,
+            initfile => '/tmp/procstats.yml',
+        },
+    );
+
+Example:
+
+    #!/usr/bin/perl
+    use strict;
+    use warnings;
+    use Sys::Statistics::Linux;
+
+    my $lxs = Sys::Statistics::Linux->new(
+        pgswstats => {
+            init => 1,
+            initfile => '/tmp/pgswstats.yml'
+        }
+    );
+
+    $lxs->get(); # without to sleep
+
+The initial statistics are stored to the temporary file:
+
+    #> cat /tmp/pgswstats.yml
+    --- 
+    pgfault: 397040955
+    pgmajfault: 4611
+    pgpgin: 21531693
+    pgpgout: 49511043
+    pswpin: 8
+    pswpout: 272
+    time: 1236783534.9328
+
+Every time you call the script the initial statistics are loaded/stored from/to the file.
+This could be helpful if you doesn't run it as daemon and if you want to calculate the
+average load of your system since the last call. Do you understand? I hope so :)
 
 To get more informations about the statistics refer the different modules of the distribution.
 
@@ -364,7 +433,7 @@
 =cut
 
 package Sys::Statistics::Linux;
-our $VERSION = '0.48';
+our $VERSION = '0.49';
 
 use strict;
 use warnings;

Modified: trunk/libsys-statistics-linux-perl/lib/Sys/Statistics/Linux/CpuStats.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libsys-statistics-linux-perl/lib/Sys/Statistics/Linux/CpuStats.pm?rev=32135&op=diff
==============================================================================
--- trunk/libsys-statistics-linux-perl/lib/Sys/Statistics/Linux/CpuStats.pm (original)
+++ trunk/libsys-statistics-linux-perl/lib/Sys/Statistics/Linux/CpuStats.pm Mon Mar 16 01:06:38 2009
@@ -101,7 +101,7 @@
 use warnings;
 use Carp qw(croak);
 
-our $VERSION = '0.16';
+our $VERSION = '0.17';
 
 sub new {
     my ($class, %opts) = @_;
@@ -194,9 +194,11 @@
             if (!defined $icpu->{$k}) {
                 croak "$class: not defined key found '$k'";
             }
+
             if ($v !~ /^\d+\z/ || $dcpu->{$k} !~ /^\d+\z/) {
                 croak "$class: invalid value for key '$k'";
             }
+
             $dcpu->{$k} -= $icpu->{$k};
             $icpu->{$k}  = $v;
             $uptime += $dcpu->{$k};
@@ -205,6 +207,8 @@
         foreach my $k (keys %{$dcpu}) {
             if ($dcpu->{$k} > 0) {
                 $dcpu->{$k} = sprintf('%.2f', 100 * $dcpu->{$k} / $uptime);
+            } elsif ($dcpu->{$k} < 0) {
+                $dcpu->{$k} = sprintf('%.2f', 0);
             } else {
                 $dcpu->{$k} = sprintf('%.2f', $dcpu->{$k});
             }

Modified: trunk/libsys-statistics-linux-perl/lib/Sys/Statistics/Linux/DiskStats.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libsys-statistics-linux-perl/lib/Sys/Statistics/Linux/DiskStats.pm?rev=32135&op=diff
==============================================================================
--- trunk/libsys-statistics-linux-perl/lib/Sys/Statistics/Linux/DiskStats.pm (original)
+++ trunk/libsys-statistics-linux-perl/lib/Sys/Statistics/Linux/DiskStats.pm Mon Mar 16 01:06:38 2009
@@ -93,7 +93,7 @@
 use Carp qw(croak);
 use Time::HiRes;
 
-our $VERSION = '0.20';
+our $VERSION = '0.21';
 
 sub new {
     my ($class, %opts) = @_;
@@ -299,16 +299,18 @@
             if (!defined $idev->{$k}) {
                 croak "$class: not defined key found '$k'";
             }
+
             if ($v !~ /^\d+\z/ || $ldev->{$k} !~ /^\d+\z/) {
                 croak "$class: invalid value for key '$k'";
             }
 
-            $ldev->{$k} =
-                $ldev->{$k} == $idev->{$k}
-                    ? sprintf('%.2f', 0)
-                    : $delta > 0
-                        ? sprintf('%.2f', ($ldev->{$k} - $idev->{$k}) / $delta)
-                        : sprintf('%.2f', $ldev->{$k} - $idev->{$k});
+            if ($ldev->{$k} == $idev->{$k} || $idev->{$k} > $ldev->{$k}) {
+                $ldev->{$k} = sprintf('%.2f', 0);
+            } elsif ($delta > 0) {
+                $ldev->{$k} = sprintf('%.2f', ($ldev->{$k} - $idev->{$k}) / $delta);
+            } else {
+                $ldev->{$k} = sprintf('%.2f', $ldev->{$k} - $idev->{$k});
+            }
 
             $idev->{$k}  = $v;
         }

Modified: trunk/libsys-statistics-linux-perl/lib/Sys/Statistics/Linux/NetStats.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libsys-statistics-linux-perl/lib/Sys/Statistics/Linux/NetStats.pm?rev=32135&op=diff
==============================================================================
--- trunk/libsys-statistics-linux-perl/lib/Sys/Statistics/Linux/NetStats.pm (original)
+++ trunk/libsys-statistics-linux-perl/lib/Sys/Statistics/Linux/NetStats.pm Mon Mar 16 01:06:38 2009
@@ -107,7 +107,7 @@
 use Carp qw(croak);
 use Time::HiRes;
 
-our $VERSION = '0.16';
+our $VERSION = '0.17';
 
 sub new {
     my ($class, %opts) = @_;
@@ -212,17 +212,18 @@
             if (!defined $idev->{$k}) {
                 croak "$class: not defined key found '$k'";
             }
+
             if ($v !~ /^\d+\z/ || $ldev->{$k} !~ /^\d+\z/) {
                 croak "$class: invalid value for key '$k'";
             }
 
-            $ldev->{$k} =
-                $ldev->{$k} == $idev->{$k}
-                    ? sprintf('%.2f', 0)
-                    : $delta > 0
-                        ? sprintf('%.2f', ($ldev->{$k} - $idev->{$k}) / $delta)
-                        : sprintf('%.2f', $ldev->{$k} - $idev->{$k});
-
+            if ($ldev->{$k} == $idev->{$k} || $idev->{$k} > $ldev->{$k}) {
+                $ldev->{$k} = sprintf('%.2f', 0);
+            } elsif ($delta > 0) {
+                $ldev->{$k} = sprintf('%.2f', ($ldev->{$k} - $idev->{$k}) / $delta);
+            } else {
+                $ldev->{$k} = sprintf('%.2f', $ldev->{$k} - $idev->{$k});
+            }
 
             $idev->{$k} = $v;
         }

Modified: trunk/libsys-statistics-linux-perl/lib/Sys/Statistics/Linux/PgSwStats.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libsys-statistics-linux-perl/lib/Sys/Statistics/Linux/PgSwStats.pm?rev=32135&op=diff
==============================================================================
--- trunk/libsys-statistics-linux-perl/lib/Sys/Statistics/Linux/PgSwStats.pm (original)
+++ trunk/libsys-statistics-linux-perl/lib/Sys/Statistics/Linux/PgSwStats.pm Mon Mar 16 01:06:38 2009
@@ -94,7 +94,7 @@
 use Carp qw(croak);
 use Time::HiRes;
 
-our $VERSION = '0.14';
+our $VERSION = '0.15';
 
 sub new {
     my ($class, %opts) = @_;
@@ -195,16 +195,18 @@
         if (!defined $istat->{$k} || !defined $lstat->{$k}) {
             croak "$class: not defined key found '$k'";
         }
+
         if ($v !~ /^\d+\z/ || $istat->{$k} !~ /^\d+\z/) {
             croak "$class: invalid value for key '$k'";
         }
 
-        $lstat->{$k} =
-            $lstat->{$k} == $istat->{$k}
-                ? sprintf('%.2f', 0)
-                : $delta > 0
-                    ? sprintf('%.2f', ($lstat->{$k} - $istat->{$k}) / $delta)
-                    : sprintf('%.2f', $lstat->{$k} - $istat->{$k});
+        if ($lstat->{$k} == $istat->{$k} || $istat->{$k} > $lstat->{$k}) {
+            $lstat->{$k} = sprintf('%.2f', 0);
+        } elsif ($delta > 0) {
+            $lstat->{$k} = sprintf('%.2f', ($lstat->{$k} - $istat->{$k}) / $delta);
+        } else {
+            $lstat->{$k} = sprintf('%.2f', $lstat->{$k} - $istat->{$k});
+        }
 
         $istat->{$k}  = $v;
     }

Modified: trunk/libsys-statistics-linux-perl/lib/Sys/Statistics/Linux/ProcStats.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libsys-statistics-linux-perl/lib/Sys/Statistics/Linux/ProcStats.pm?rev=32135&op=diff
==============================================================================
--- trunk/libsys-statistics-linux-perl/lib/Sys/Statistics/Linux/ProcStats.pm (original)
+++ trunk/libsys-statistics-linux-perl/lib/Sys/Statistics/Linux/ProcStats.pm Mon Mar 16 01:06:38 2009
@@ -89,7 +89,7 @@
 use Carp qw(croak);
 use Time::HiRes;
 
-our $VERSION = '0.15';
+our $VERSION = '0.16';
 
 sub new {
     my ($class, %opts) = @_;
@@ -197,12 +197,13 @@
 
     my $new_init = $lstat->{new};
 
-    $lstat->{new} =
-        $lstat->{new} == $istat->{new}
-            ? sprintf('%.2f', 0)
-            : $delta > 0
-                ? sprintf('%.2f', ($new_init - $istat->{new}) / $delta )
-                : sprintf('%.2f', $new_init - $istat->{new});
+    if ($lstat->{new} == $istat->{new} || $istat->{new} > $lstat->{new}) {
+        $lstat->{new} = sprintf('%.2f', 0);
+    } elsif ($delta > 0) {
+        $lstat->{new} = sprintf('%.2f', ($new_init - $istat->{new}) / $delta );
+    } else {
+        $lstat->{new} = sprintf('%.2f', $new_init - $istat->{new});
+    }
 
     $istat->{new} = $new_init;
 }

Modified: trunk/libsys-statistics-linux-perl/lib/Sys/Statistics/Linux/Processes.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libsys-statistics-linux-perl/lib/Sys/Statistics/Linux/Processes.pm?rev=32135&op=diff
==============================================================================
--- trunk/libsys-statistics-linux-perl/lib/Sys/Statistics/Linux/Processes.pm (original)
+++ trunk/libsys-statistics-linux-perl/lib/Sys/Statistics/Linux/Processes.pm Mon Mar 16 01:06:38 2009
@@ -136,7 +136,7 @@
 use Time::HiRes;
 use constant NUMBER => qr/^-{0,1}\d+(?:\.\d+){0,1}\z/;
 
-our $VERSION = '0.24';
+our $VERSION = '0.25';
 our $PAGES_TO_BYTES = 0;
 
 sub new {
@@ -144,12 +144,13 @@
 
     my %self = (
         files => {
-            basedir   => '/proc',
-            p_stat    => 'stat',
-            p_statm   => 'statm',
-            p_status  => 'status',
-            p_cmdline => 'cmdline',
-            p_wchan   => 'wchan',
+            basedir => '/proc',
+            stat    => 'stat',
+            statm   => 'statm',
+            status  => 'status',
+            cmdline => 'cmdline',
+            wchan   => 'wchan',
+            fd      => 'fd',
         },
     );
 
@@ -210,7 +211,7 @@
     }
 
     foreach my $pid (@$pids) {
-        if (open my $fh, '<', "$file->{basedir}/$pid/$file->{p_stat}") {
+        if (open my $fh, '<', "$file->{basedir}/$pid/$file->{stat}") {
             @{$stats{$pid}}{qw(
                 minflt cminflt mayflt cmayflt utime
                 stime cutime cstime sttime
@@ -249,7 +250,7 @@
     PID: foreach my $pid (@$pids) {
 
         # memory usage for each process
-        if (open my $fh, '<', "$file->{basedir}/$pid/$file->{p_statm}") {
+        if (open my $fh, '<', "$file->{basedir}/$pid/$file->{statm}") {
             #   size       total program size
             #   resident   resident set size
             #   share      shared pages
@@ -270,7 +271,7 @@
         }
 
         # different other informations for each process
-        if (open my $fh, '<', "$file->{basedir}/$pid/$file->{p_stat}") {
+        if (open my $fh, '<', "$file->{basedir}/$pid/$file->{stat}") {
             @{$stats{$pid}}{qw(
                 cmd     state   ppid    pgrp    session ttynr   minflt
                 cminflt mayflt  cmayflt utime   stime   cutime  cstime
@@ -288,7 +289,7 @@
         $stats{$pid}{actime} = "$d:".sprintf('%02d:%02d:%02d', $h, $m, $s);
 
         # determine the owner of the process
-        if (open my $fh, '<', "$file->{basedir}/$pid/$file->{p_status}") {
+        if (open my $fh, '<', "$file->{basedir}/$pid/$file->{status}") {
             while (my $line = <$fh>) {
                 next unless $line =~ /^Uid:(?:\s+|\t+)(\d+)/;
                 $stats{$pid}{owner} = getpwuid($1) || 'N/a';
@@ -301,7 +302,7 @@
         }
 
         # command line for each process
-        if (open my $fh, '<', "$file->{basedir}/$pid/$file->{p_cmdline}") {
+        if (open my $fh, '<', "$file->{basedir}/$pid/$file->{cmdline}") {
             $stats{$pid}{cmdline} = <$fh>;
             if ($stats{$pid}{cmdline}) {
                 $stats{$pid}{cmdline} =~ s/\0/ /g;
@@ -316,7 +317,7 @@
             next PID;
         }
 
-        if (open my $fh, '<', "$file->{basedir}/$pid/$file->{p_wchan}") {
+        if (open my $fh, '<', "$file->{basedir}/$pid/$file->{wchan}") {
             $stats{$pid}{wchan} = <$fh>;
             chomp($stats{$pid}{wchan});
         } else {
@@ -326,9 +327,9 @@
 
         $stats{$pid}{fd} = { };
 
-        if (opendir my $dh, "$file->{basedir}/$pid/fd") {
+        if (opendir my $dh, "$file->{basedir}/$pid/$file->{fd}") {
             foreach my $link (grep !/^\.+\z/, readdir($dh)) {
-                if (my $target = readlink("$file->{basedir}/$pid/fd/$link")) {
+                if (my $target = readlink("$file->{basedir}/$pid/$file->{fd}/$link")) {
                     $stats{$pid}{fd}{$link} = $target;
                 }
             }

Modified: trunk/libsys-statistics-linux-perl/t/050-pgswstats.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libsys-statistics-linux-perl/t/050-pgswstats.t?rev=32135&op=diff
==============================================================================
--- trunk/libsys-statistics-linux-perl/t/050-pgswstats.t (original)
+++ trunk/libsys-statistics-linux-perl/t/050-pgswstats.t Mon Mar 16 01:06:38 2009
@@ -13,7 +13,7 @@
 my $sys = Sys::Statistics::Linux->new();
 
 if (!-r '/proc/diskstats' || !-r '/proc/partitions') {
-    plan skip_all => "your system seems to be a virtual machine that doesn't provide all statistics";
+    plan skip_all => "it seems that your system doesn't provide paging/swapping statistics";
     exit(0);
 }
 

Modified: trunk/libsys-statistics-linux-perl/t/070-sockstats.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libsys-statistics-linux-perl/t/070-sockstats.t?rev=32135&op=diff
==============================================================================
--- trunk/libsys-statistics-linux-perl/t/070-sockstats.t (original)
+++ trunk/libsys-statistics-linux-perl/t/070-sockstats.t Mon Mar 16 01:06:38 2009
@@ -13,7 +13,7 @@
 my $sys = Sys::Statistics::Linux->new();
 
 if (!-r '/proc/diskstats' || !-r '/proc/partitions') {
-    plan skip_all => "your system seems to be a virtual machine that doesn't provide all statistics";
+    plan skip_all => "it seems that your system doesn't provide socket statistics";
     exit(0);
 }
 

Modified: trunk/libsys-statistics-linux-perl/t/080-diskstats.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libsys-statistics-linux-perl/t/080-diskstats.t?rev=32135&op=diff
==============================================================================
--- trunk/libsys-statistics-linux-perl/t/080-diskstats.t (original)
+++ trunk/libsys-statistics-linux-perl/t/080-diskstats.t Mon Mar 16 01:06:38 2009
@@ -17,7 +17,7 @@
 my $sys = Sys::Statistics::Linux->new();
 
 if (!-r '/proc/diskstats' || !-r '/proc/partitions') {
-    plan skip_all => "your system seems to be a virtual machine that doesn't provide all statistics";
+    plan skip_all => "your system doesn't provide disk statistics - /proc/diskstats and /proc/partitions is not readable";
     exit(0);
 }
 

Modified: trunk/libsys-statistics-linux-perl/t/120-processes.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libsys-statistics-linux-perl/t/120-processes.t?rev=32135&op=diff
==============================================================================
--- trunk/libsys-statistics-linux-perl/t/120-processes.t (original)
+++ trunk/libsys-statistics-linux-perl/t/120-processes.t Mon Mar 16 01:06:38 2009
@@ -1,7 +1,14 @@
 use strict;
 use warnings;
-use Test::More tests => 35;
+use Test::More;
 use Sys::Statistics::Linux;
+
+for my $f ("/proc/$$/stat","/proc/$$/statm","/proc/$$/status","/proc/$$/cmdline","/proc/$$/wchan") {
+    if (!-r $f) {
+        plan skip_all => "$f is not readable";
+        exit(0);
+    }
+}
 
 my @processes = qw(
     ppid
@@ -46,6 +53,13 @@
 sleep(1);
 my $stats = $sys->get;
 
+if (!scalar keys %{$stats->processes}) {
+    plan skip_all => "processlist is empty";
+    exit(0);
+}
+
+plan tests => 35;
+
 for my $pid (keys %{$stats->processes}) {
    ok(defined $stats->processes->{$pid}->{$_}, "checking processes $_") for @processes;
    last; # we check only one process, that should be enough

Modified: trunk/libsys-statistics-linux-perl/t/130-search.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libsys-statistics-linux-perl/t/130-search.t?rev=32135&op=diff
==============================================================================
--- trunk/libsys-statistics-linux-perl/t/130-search.t (original)
+++ trunk/libsys-statistics-linux-perl/t/130-search.t Mon Mar 16 01:06:38 2009
@@ -1,6 +1,6 @@
 use strict;
 use warnings;
-use Test::More tests => 11;
+use Test::More tests => 10;
 use Sys::Statistics::Linux;
 use Data::Dumper;
 
@@ -11,13 +11,11 @@
    procstats => 1,
    memstats  => 1,
    diskusage => 1,
-   processes => 1,
 );
 
 sleep 1;
 
 my $stat = $sys->get();
-my $pid  = (keys %{$stat->{processes}})[0];
 
 # just some simple searches that should match every time
 my $foo = $stat->search({
@@ -25,10 +23,9 @@
    procstats => { count => 'ne:1' },
    memstats  => { memtotal => 'gt:1' },
    diskusage => { usageper => qr/\d+/ },
-   processes => { $pid => { ppid => qr/\d+/ } },
 });
 
-foreach my $key (qw/cpustats procstats memstats diskusage processes/) {
+foreach my $key (qw/cpustats procstats memstats diskusage/) {
     ok(exists $foo->{$key} && ref($foo->{$key}) eq 'HASH', "checking $key");
 }
 

Modified: trunk/libsys-statistics-linux-perl/t/140-psfind.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libsys-statistics-linux-perl/t/140-psfind.t?rev=32135&op=diff
==============================================================================
--- trunk/libsys-statistics-linux-perl/t/140-psfind.t (original)
+++ trunk/libsys-statistics-linux-perl/t/140-psfind.t Mon Mar 16 01:06:38 2009
@@ -1,11 +1,25 @@
 use strict;
 use warnings;
-use Test::More tests => 1;
+use Test::More;
 use Sys::Statistics::Linux;
+
+for my $f ("/proc/$$/stat","/proc/$$/statm","/proc/$$/status","/proc/$$/cmdline","/proc/$$/wchan") {
+    if (!-r $f) {
+        plan skip_all => "$f is not readable";
+        exit(0);
+    }
+}
 
 my $sys = Sys::Statistics::Linux->new();
 $sys->set(processes => 1);
 sleep 1;
 my $stat = $sys->get;
+
+if (!scalar keys %{$stat->processes}) {
+    plan skip_all => "processlist is empty";
+    exit(0);
+}
+
+plan tests => 1;
 my $foo  = $stat->psfind({cmd => qr/\w/});
 ok(@{$foo}, "checking psfind");

Modified: trunk/libsys-statistics-linux-perl/t/150-pstop.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libsys-statistics-linux-perl/t/150-pstop.t?rev=32135&op=diff
==============================================================================
--- trunk/libsys-statistics-linux-perl/t/150-pstop.t (original)
+++ trunk/libsys-statistics-linux-perl/t/150-pstop.t Mon Mar 16 01:06:38 2009
@@ -1,12 +1,27 @@
 use strict;
 use warnings;
-use Test::More tests => 1;
+use Test::More;
 use Sys::Statistics::Linux;
+
+for my $f ("/proc/$$/stat","/proc/$$/statm","/proc/$$/status","/proc/$$/cmdline","/proc/$$/wchan") {
+    if (!-r $f) {
+        plan skip_all => "$f is not readable";
+        exit(0);
+    }
+}
 
 my $sys = Sys::Statistics::Linux->new();
 $sys->set(processes => 1);
 sleep 1;
-my $stat  = $sys->get;
+my $stat = $sys->get;
+
+if (!scalar keys %{$stat->processes}) {
+    plan skip_all => "processlist is empty";
+    exit(0);
+}
+
+plan tests => 1;
+
 my @top   = $stat->pstop( ttime => 5 );
 my $count = scalar keys %{ $stat->{processes} };
 




More information about the Pkg-perl-cvs-commits mailing list