This file is indexed.

/usr/share/fusioninventory/lib/FusionInventory/Agent/Task/Inventory/AIX/CPU.pm is in fusioninventory-agent 1:2.3.10.1-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
package FusionInventory::Agent::Task::Inventory::AIX::CPU;

use strict;
use warnings;

use FusionInventory::Agent::Tools;

sub isEnabled {
    return 1;
}


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

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

    foreach my $cpu (_getCPUs(
        command => 'lsdev -Cc processor -F name',
        logger  => $logger
    )) {
        $inventory->addEntry(
            section => 'CPUS',
            entry   => $cpu
        );
    }
}

sub _getCPUs {
    my $handle = getFileHandle(@_);
    return unless $handle;

    my $aixversion = getFirstLine(command => 'uname -v');

    my @cpus;
    while (my $line = <$handle>) {
        chomp $line;
        my $device = $line;

        my $format = $aixversion >= 5 ?
            'type:frequency:frequency' : 'type';

        my @lsattr = getAllLines(
            command => "lsattr -EOl $device -a '$format'",
        );

        my $cpu = {
            THREAD => 1
        };

        my $smt_threads = getFirstLine(command => "lsattr -EOl $device -a 'state:type:smt_threads'");
        if ($smt_threads && $smt_threads =~ /:(\d+)$/) {
            $cpu->{THREAD} = $1;
        }


        # drop headers
        shift @lsattr;

        # use first line to compute name, frequency and number of threads
        my @infos = split(/:/, $lsattr[0]);

        $cpu->{NAME} = $infos[0];
        $cpu->{NAME} =~ s/_/ /;

        if ($aixversion >= 5) {
            $cpu->{SPEED} = ($infos[1] % 1000000) >= 50000 ?
                int($infos[1] / 1000000) + 1 : int($infos[1] / 1000000);
        } else {
            # On older models, frequency is based on cpu model and uname
            SWITCH: {
                if (
                    $infos[0] eq "PowerPC"     or
                    $infos[0] eq "PowerPC_601" or
                    $infos[0] eq "PowerPC_604"
                ) {
                    my $uname = getFirstLine(command => 'uname -m');
                    $cpu->{SPEED} =
                        $uname =~ /E1D|EAD|C1D|R04|C4D|R4D/ ?  12.2 :
                        $uname =~ /34M/                     ? 133   :
                        $uname =~ /N4D/                     ? 150   :
                        $uname =~ /X4M|X4D/                 ? 200   :
                        $uname =~ /N4E|K04|K44/             ? 225   :
                        $uname =~ /N4F/                     ? 320   :
                        $uname =~ /K45/                     ? 360   :
                                                              undef ;
                    last SWITCH;
                }

                if ($infos[0] eq "PowerPC_RS64_III") {
                    $cpu->{SPEED} = 400;
                    last SWITCH;
                }

                if ($infos[0] eq "PowerPC_620") {
                    $cpu->{SPEED} = 172;
                    last SWITCH;
                }

                $cpu->{SPEED} = 225;
            }
        }

        # compute core number from lines number
        $cpu->{CORE} = scalar @lsattr;

        push @cpus, $cpu;
    }
    close $handle;

    return @cpus;
}

1;