The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Linux::Info::DiskStats - Collect Linux disks statistics.

SYNOPSIS

    use Linux::Info::DiskStats;

    my $config = Linux::Info::DiskStats::Options->new({backwards_compatibility => 0});
    my $lxs = Linux::Info::DiskStats->new($config);
    $lxs->init;
    sleep 1;
    my $stat = $lxs->get;

Or

    my $config = Linux::Info::DiskStats::Options->new({backwards_compatibility => 1,
                                                       global_block_size => 4096});
    my $lxs = Linux::Info::DiskStats->new($config);
    $lxs->init;
    my $stat = $lxs->get;

DESCRIPTION

Linux::Info::DiskStats gathers disk statistics from the virtual /proc filesystem (procfs).

For more information read the documentation of the front-end module Linux::Info.

DISK STATISTICS

The disk statics will depend on the kernel version that is running in the host. See the "SEE ALSO" in Linux::Info::DiskStats section for more details on that.

Also, this module produces two types of statistics:

  • Backwards compatible with Linux::Info versions 1.5 and lower.

  • New fields since version 1.6 and higher. These fields are also incompatible with those produced by Sys::Statistics::Linux.

Backwards compatible fields

Those fields are generated from /proc/diskstats or /proc/partitions, depending on the kernel version.

Not necessarily those fields will have a direct correlation with the fields on the /proc directory, some of them are basically calculations and others are not even statistics (major and minor).

These fields are kept only to provide compatibility, but it is highly recommended to not use compatibility mode since some statistics won't be exposed and you can always execute the calculations yourself with that set.

  • major: The mayor number of the disk

  • minor: The minor number of the disk

  • rdreq: Number of read requests that were made to physical disk per second.

  • rdbyt: Number of bytes that were read from physical disk per second.

  • wrtreq: Number of write requests that were made to physical disk per second.

  • wrtbyt: Number of bytes that were written to physical disk per second.

  • ttreq: Total number of requests were made from/to physical disk per second.

  • ttbyt: Total number of bytes transmitted from/to physical disk per second.

The "new" fields

Actually, those fields are not really new: they are the almost exact representation of those available on the respective /proc file, with small differences in the fields naming in this module in order to make it easier to type in.

These are the fields you want to use, if possible. It is also possible to have the calculated fields by using the module Linux::Info::DiskStats::Calculated.

METHODS

new

Call new to create a new object.

    my $lxs = Linux::Info::DiskStats->new($opts);

Where $opts is a Linux::Info::DiskStats::Options.

init

Call init to initialize the statistics.

    $lxs->init;

get

Call get to get the statistics. get() returns the statistics as a hash reference.

    my $stat = $lxs->get;

raw

Get raw values, retuned as an hash reference.

fields_read

Returns an integer telling the number of fields process in each line from the source file.

EXPORTS

Nothing.

SEE ALSO

AUTHOR

Alceu Rodrigues de Freitas Junior, <glasswalk3r@yahoo.com.br>

COPYRIGHT AND LICENSE

This software is copyright (c) 2015 of Alceu Rodrigues de Freitas Junior, <glasswalk3r@yahoo.com.br>

This file is part of Linux Info project.

Linux-Info is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Linux-Info is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Linux Info. If not, see <http://www.gnu.org/licenses/>.