The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Linux::Info::DiskUsage - Collect linux disk usage.

SYNOPSIS

    use Linux::Info::DiskUsage;

    my $lxs  = Linux::Info::DiskUsage->new;
    my $stat = $lxs->get;

DESCRIPTION

Linux::Info::DiskUsage gathers the disk usage. Previous versions of this module used the df command to retrieve such information. Since release 0.08, df was deprecated to avoid doing additional syscalls and potencially dangerous environment variables manipulations. See SEE ALSO section for references about the new implementation.

General output should be the same as generated by df, but output is filtered based on "valid" file systems that are mounted (to avoid what df defines as "dummy" file systems). See the new and default_fs methods for more details.

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

DISK USAGE INFORMATIONS

  • total - The total size of the disk.

  • usage - The used disk space in kilobytes.

  • free - The free disk space in kilobytes.

  • usageper - The used disk space in percent.

  • mountpoint - The moint point of the disk.

In the event that the mount point doesn't have some or all this information (for example, AUFS mount points used by Docker), the values will be automatically assigned as "-" (without quotes).

Optionally this class might also include inodes information as defined in Filesys::Df. Check the new method description for more details.

METHODS

new()

Call new() to create a new object.

    my $lxs = Linux::Info::DiskUsage->new;

Optionally it accepts two positional parameters as well.

It's possible to pass additional file system names (as available on /proc/mounts) so you can see more mounted file systems in the returned value of get method. The expected parameter for that must be an array reference, as shown below:

    Linux::Info::DiskUsage->new([qw(reiserfs xfs)]);

Additional values given like that will be added to the default set of accepted values.

This class also accepts a second parameter that defines if the instance will also provide inode information from the file systems as well. This extends and breaks compatibility with Sys::Statistics::Linux::FileStats interface. To enable that, just pass one to enabled it, for example:

    Linux::Info::DiskUsage->new([qw(reiserfs xfs)], 1);

The interface of Linux::Info also remains the same, so you can't use these extended options from it. This might change in future implementations, but for now you need to create an instance from Linux::Info::DiskUsage directly from new.

get()

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

    my $stat = $lxs->get;

The hash reference will have keys and values as described in DISK USAGE INFORMATIONS section.

default_fs

Returns and array reference with the file systems that are mounted and will have their storage space checked by default.

This method can be invoke both directly from the class and from instances of it.

EXPORTS

Nothing.

SEE ALSO

AUTHOR

Alceu Rodrigues de Freitas Junior, <arfreitas@cpan.org>.

COPYRIGHT AND LICENSE

This software is copyright (c) 2015 of Alceu Rodrigues de Freitas Junior, <arfreitas@cpan.org>.

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/>.