Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > 272d067b8f31b2ea360e5e099db4b3dc > files > 36

perl-RPC-XML-0.770.0-3.mga4.noarch.rpm

###############################################################################
#
#   Sub Name:       linux_proc_cpuinfo
#
#   Description:    Read the /proc/cpuinfo on a Linux server and return a
#                   STRUCT with the information.
#
#   Arguments:      None.
#
#   Returns:        hashref
#
###############################################################################
sub linux_proc_sysinfo
{
    use strict;

    my (%cpuinfo, $line, $key, $value);
    local *F;

    open(F, '/proc/cpuinfo') or
        return RPC::XML::fault->new(501, "Cannot open /proc/cpuinfo: $!");

    while (defined($line = <F>))
    {
        chomp $line;
        next if ($line =~ /^\s*$/);

        ($key, $value) = split(/\s+:\s+/, $line, 2);
        $key =~ s/ /_/g;
        $cpuinfo{$key} = ($key eq 'flags') ? [ split(/ /, $value) ] : $value;
    }
    close(F);

    \%cpuinfo;
}