<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">package GLPI::Agent::Task::Inventory::Linux::Alpha::CPU;

use strict;
use warnings;

use parent 'GLPI::Agent::Task::Inventory::Module';

use GLPI::Agent::Tools;
use GLPI::Agent::Tools::Linux;

use constant    category    =&gt; "cpu";

sub isEnabled {
    return has_file('/proc/cpuinfo');
};

sub doInventory {
    my (%params) = @_;

    my $inventory = $params{inventory};
    my $logger    = $params{logger};

    foreach my $cpu (_getCPUsFromProc(
        logger =&gt; $logger, file =&gt; '/proc/cpuinfo')
    ) {
        $inventory-&gt;addEntry(
            section =&gt; 'CPUS',
            entry   =&gt; $cpu
        );
    }
}

sub _getCPUsFromProc {
    my @cpus;
    foreach my $cpu (getCPUsFromProc(@_)) {

        my $speed;
        if (
            $cpu-&gt;{'cycle frequency [hz]'} &amp;&amp;
            $cpu-&gt;{'cycle frequency [hz]'} =~ /(\d+)000000/
        ) {
            $speed = $1;
        }

        push @cpus, {
            ARCH   =&gt; 'alpha',
            NAME   =&gt; $cpu-&gt;{processor},
            SERIAL =&gt; $cpu-&gt;{'cpu serial number'},
            SPEED  =&gt; $speed
        };
    }

    return @cpus;
}

1;
</pre></body></html>