Linux::Cpuinfo(3) User Contributed Perl Documentation Linux::Cpuinfo(3)
NAME
Linux::Cpuinfo - Object Oriented Interface to /proc/cpuinfo
SYNOPSIS
# Old interface ( for single processor devices )
use Linux::Cpuinfo;
my $cpu = Linux::Cpuinfo->new();
die ('Could not find cpu info (does /proc/cpuinfo exists?)')
unless ref $cpu;
print $cpu->model_name();
# New Interface ( copes with SMP ).
my $cpuinfo = Linux::Cpuinfo->new();
$cnt = $cpuinfo->num_cpus(); # > 1 for an SMP system
foreach my $cpu ( $cpuinfo->cpus() )
{
print $cpu->bogomips(),"\n";
}
DESCRIPTION
On Linux systems various information about the CPU ( or CPUs ) in the
computer can be gleaned from "/proc/cpuinfo". This module provides an
object oriented interface to that information for relatively simple use
in Perl programs.
METHODS
The interface has changed between revisions 1.2 and 1.3 of this module
in order to deal with systems with multiple CPUs - now the details of a
CPU are acquired by the methods of the Linux::Cpuinfo::Cpu objects
returned by the "cpu()" and "cpus()" methods of this class. However in
order to retain backward compatibility if the methods described for
Linux::Cpuinfo::Cpu are called a Linux::Cpuinfo object then it will
work as previously - returning the details of the sole CPU on a single
processor system and the last discovered
CPU on system with multiple processors ( this was the implicit
behaviour on previous versions). Whilst not strictly deprecated this
interface is not the recommended one.
cpuinfo
Returns a blessed object suitable for calling the rest of the
methods on or a false value if for some reason "/proc/cpuinfo" cant
be opened. The first argument can be an alternative file that
provides identical information. You may also supply a hashref
containing other arguments - the valid keys are
NoFatal
The default behaviour is for the method to croak if an attribute
is requested that is not available on this particular CPU. If
this argument is supplied with a true value then the method will
return undef instead.
num_cpus
Returns the number of CPUs reported for this system.
cpu SCALAR $cpu
Returns an object of type Linux::Cpuinfo::Cpu corresponding to the
CPU of index $cpu ( where $cpu >= 0 and $cpu < num_cpus() ) - if
$cpu is omitted this will return an object correspnding to the last
CPU found.
If $cpu is out of bounds with respect to the number of CPUs then it
will be set to the first or last CPU ( depending whether $cpu was <
0 or >num_cpus )
cpus
Returns a list containing objects of type Linux::Cpuinfo::Cpu
corresponding to the CPUs discovered in this system. If the
method is called in a scalar context it will return a reference to
an array of those objects.
PER CPU METHODS OF Linux::Cpuinfo::Cpu
Note that not all of the methods listed here are available on all CPU
types. For instance, MIPS CPUs have no cpuid instruction, but might
sport a byte order attribute.
There are also some other methods available for some CPUs which aren't
listed here.
processor
This is the index of the processor this information is for, it will
be zero for a the first CPU (which is the only one on single-
proccessor systems), one for the second and so on.
vendor_id
This is a vendor defined string for X86 CPUs such as 'GenuineIntel'
or 'AuthenticAMD'. 12 bytes long, since it is returned via three 32
byte long registers.
cpu_family
This should return an integer that will indicate the 'family' of
the processor - This is for instance '6' for a Pentium III. Might
be undefined for non-X86 CPUs.
model or cpu_model
An integer that is probably vendor dependent that indicates their
version of the above cpu_family
model_name
A string such as 'Pentium III (Coppermine)'.
stepping
I'm lead to believe this is a version increment used by intel.
cpu_mhz
I guess this is self explanatory - it might however be different to
what it says on the box. The Mhz is measured at boot time by the
kernel and represents the true Mhz at that time.
bus_mhz
The MHz of the bus system.
cache_size
The cache size for this processor - it might well have the units
appended ( such as 'KB' )
fdiv_bug
True if this bug is present in the processor.
hlt_bug
True if this bug is present in the processor.
sep_bug
True if this bug is present in the processor.
f00f_bug
True if this bug is present in the processor.
coma_bug
True if this bug is present in the processor.
fpu True if the CPU has a floating point unit.
fpu_exception
True if the floating point unit can throw an exception.
cpuid_level
The "cpuid" assembler instruction is only present on X86 CPUs. This
attribute represents the level of the instruction that is supported
by the CPU. The first CPUs had only level 1, newer chips have more
levels and can thus return more information.
wp No idea what this is on X86 CPUs.
flags
This is the set of flags that the CPU supports - this is returned
as an array reference.
byte_order
The byte order of the CPU, might be little endian or big endian, or
undefined for unknown.
bogomips
A system constant calculated when the kernel is booted - it is a
(rather poor) measure of the CPU's performance.
EXPORT
None by default.
BUGS
The enormous bug in this is that I didnt realize when I made this that
the contents of "/proc/cpuinfo " are different for different
processors.
I really would be indebted if Linux users from other than x86
processors would help me document this properly.
The source can be found at
https://github.com/jonathanstowe/Linux-Cpuinfo
Please feel free to fork, send patches etc.
COPYRIGHT AND LICENSE
See the README file in the Distribution Kit
AUTHOR
Jonathan Stowe, <jns@gellyfish.co.uk>
SEE ALSO
perl.
perl v5.24.1 2015-06-07 Linux::Cpuinfo(3)
permalink to the Linux::Cpuinfo command:
https://manpage.me/?Linux::Cpuinfo
link by Name, Section, and OS version of this man page:
/?q=Linux::Cpuinfo&sektion=3&manpath=FreeBSD+11.1-RELEASE+and+Ports