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

NAME

Linux::Info::SysInfo - Collect linux system information.

SYNOPSIS

    use Linux::Info::SysInfo;

    my $lxs  = Linux::Info::SysInfo->new;
    print $lxs->get_release(), "\n";

DESCRIPTION

Linux::Info::SysInfo gathers system information from the virtual /proc filesystem (procfs).

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

This class interface is incompatible with Sys::Statistics::Linux::SysInfo.

ATTRIBUTES

Generated by /proc/sys/kernel/{hostname,domainname,ostype,osrelease,version} and /proc/cpuinfo, /proc/meminfo, /proc/uptime, /proc/net/dev.

These are the following attribute available for a instance of this class:

  • hostname - The host name.

  • domain - The host domain name.

  • kernel - The kernel name.

  • release - The kernel release.

  • version - The kernel version.

  • mem - The total size of memory.

  • swap - The total size of swap space.

  • uptime - The uptime of the system.

  • idletime - The idle time of the system.

  • pcpucount - The total number of physical CPUs.

  • tcpucount - The total number of CPUs (cores, hyper threading).

  • interfaces - The interfaces of the system.

  • arch - The processor architecture (like uname -m).

  • multithread - A boolean indicating if the process has hyper threading enabled or not.

  • model - the processor name

pcpucount and tcpucount are really easy to understand. Both values are collected from /proc/cpuinfo. pcpucount is the number of physical CPUs, counted by physical id. tcpucount is just the total number counted by processor.

All attributes are read-only. Their corresponding value can will be returned upon invocation of their respective "get_" method.

METHODS

new()

Call new() to create a new object.

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

Without any parameters.

If you want to get uptime and idletime as raw value, then pass the following hash reference as parameter:

    my $lxs = Linux::Info::SysInfo->new({ raw_time => 1});

By default the raw_time attribute is false.

get_proc_arch

This method will return an integer as the architecture of the CPUs: 32 or 64 bits, depending on the flags retrieve for one CPU.

It is assumed that all CPUs will have the same flags, so this method will consider only the flags returned by the CPU with "core id" equal to 0 (in other words, the first CPU found).

get_cpu_flags

Returns an array reference with all flags retrieve from /proc/cpuinfo using the same logic described in get_proc_arch documentation.

is_multithread

A getter for the multithread attribute.

get_model

A getter for the model attribute.

EXPORTS

Nothing.

KNOWN ISSUES

Linux running on ARM processors have a different interface on /proc/cpuinfo. That means that the methods get_proc_arch and get_cpu_flags will not return their respective information. Tests for this module may fail as well.

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