Sys-Statistics-Linux

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN


        my $lxs = Sys::Statistics::Linux->new(
            processes => {
                init => 1,
                pids => [ 1, 2, 3 ]
            },
            netstats => {
                init => 1,
                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',
            },
            pgswstats => {
                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 information about the statistics refer the different modules
    of the distribution.

        sysinfo     -  Collect system information              with Sys::Statistics::Linux::SysInfo.
        cpustats    -  Collect cpu statistics                  with Sys::Statistics::Linux::CpuStats.
        procstats   -  Collect process statistics              with Sys::Statistics::Linux::ProcStats.
        memstats    -  Collect memory statistics               with Sys::Statistics::Linux::MemStats.
        pgswstats   -  Collect paging and swapping statistics  with Sys::Statistics::Linux::PgSwStats.
        netstats    -  Collect net statistics                  with Sys::Statistics::Linux::NetStats.
        sockstats   -  Collect socket statistics               with Sys::Statistics::Linux::SockStats.
        diskstats   -  Collect disk statistics                 with Sys::Statistics::Linux::DiskStats.
        diskusage   -  Collect the disk usage                  with Sys::Statistics::Linux::DiskUsage.
        loadavg     -  Collect the load average                with Sys::Statistics::Linux::LoadAVG.
        filestats   -  Collect inode statistics                with Sys::Statistics::Linux::FileStats.
        processes   -  Collect process statistics              with Sys::Statistics::Linux::Processes.

METHODS
  new()
    Call `new()' to create a new Sys::Statistics::Linux object. You can call
    `new()' with options. This options would be passed to the method
    `set()'.

    Without options

        my $lxs = Sys::Statistics::Linux->new();

    Or with options

        my $lxs = Sys::Statistics::Linux->new( cpustats => 1 );

    Would do nothing

        my $lxs = Sys::Statistics::Linux->new( cpustats => 0 );

    It's possible to call `new()' with a hash reference of options.

        my %options = (
            cpustats => 1,
            memstats => 1
        );

        my $lxs = Sys::Statistics::Linux->new(\%options);

  set()
    Call `set()' to activate or deactivate options.

    The following example would call `new()' and initialize
    `Sys::Statistics::Linux::CpuStats' and delete the object of
    `Sys::Statistics::Linux::SysInfo'.

        $lxs->set(



( run in 0.599 second using v1.01-cache-2.11-cpan-df04353d9ac )