line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::AIX::CPU; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
86858878
|
use strict; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
39
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
56
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
386
|
use FusionInventory::Agent::Tools; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
547
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub isEnabled { |
9
|
0
|
|
|
0
|
0
|
|
my (%params) = @_; |
10
|
0
|
0
|
|
|
|
|
return 0 if $params{no_category}->{cpu}; |
11
|
0
|
|
|
|
|
|
return 1; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub doInventory { |
15
|
0
|
|
|
0
|
0
|
|
my (%params) = @_; |
16
|
|
|
|
|
|
|
|
17
|
0
|
|
|
|
|
|
my $inventory = $params{inventory}; |
18
|
0
|
|
|
|
|
|
my $logger = $params{logger}; |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
foreach my $cpu (_getCPUs( |
21
|
|
|
|
|
|
|
command => 'lsdev -Cc processor -F name', |
22
|
|
|
|
|
|
|
logger => $logger |
23
|
|
|
|
|
|
|
)) { |
24
|
0
|
|
|
|
|
|
$inventory->addEntry( |
25
|
|
|
|
|
|
|
section => 'CPUS', |
26
|
|
|
|
|
|
|
entry => $cpu |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _getCPUs { |
32
|
0
|
|
|
0
|
|
|
my $handle = getFileHandle(@_); |
33
|
0
|
0
|
|
|
|
|
return unless $handle; |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
my $aixversion = getFirstLine(command => 'uname -v'); |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
my @cpus; |
38
|
0
|
|
|
|
|
|
while (my $line = <$handle>) { |
39
|
0
|
|
|
|
|
|
chomp $line; |
40
|
0
|
|
|
|
|
|
my $device = $line; |
41
|
|
|
|
|
|
|
|
42
|
0
|
0
|
|
|
|
|
my $format = $aixversion >= 5 ? |
43
|
|
|
|
|
|
|
'type:frequency:frequency' : 'type'; |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
my @lsattr = getAllLines( |
46
|
|
|
|
|
|
|
command => "lsattr -EOl $device -a '$format'", |
47
|
|
|
|
|
|
|
); |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
my $cpu = { |
50
|
|
|
|
|
|
|
THREAD => 1 |
51
|
|
|
|
|
|
|
}; |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
my $smt_threads = getFirstLine(command => "lsattr -EOl $device -a 'state:type:smt_threads'"); |
54
|
0
|
0
|
0
|
|
|
|
if ($smt_threads && $smt_threads =~ /:(\d+)$/) { |
55
|
0
|
|
|
|
|
|
$cpu->{THREAD} = $1; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# drop headers |
60
|
0
|
|
|
|
|
|
shift @lsattr; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# use first line to compute name, frequency and number of threads |
63
|
0
|
|
|
|
|
|
my @infos = split(/:/, $lsattr[0]); |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
$cpu->{NAME} = $infos[0]; |
66
|
0
|
|
|
|
|
|
$cpu->{NAME} =~ s/_/ /; |
67
|
|
|
|
|
|
|
|
68
|
0
|
0
|
|
|
|
|
if ($aixversion >= 5) { |
69
|
0
|
0
|
|
|
|
|
$cpu->{SPEED} = ($infos[1] % 1000000) >= 50000 ? |
70
|
|
|
|
|
|
|
int($infos[1] / 1000000) + 1 : int($infos[1] / 1000000); |
71
|
|
|
|
|
|
|
} else { |
72
|
|
|
|
|
|
|
# On older models, frequency is based on cpu model and uname |
73
|
|
|
|
|
|
|
SWITCH: { |
74
|
0
|
0
|
0
|
|
|
|
if ( |
|
0
|
|
0
|
|
|
|
|
75
|
|
|
|
|
|
|
$infos[0] eq "PowerPC" or |
76
|
|
|
|
|
|
|
$infos[0] eq "PowerPC_601" or |
77
|
|
|
|
|
|
|
$infos[0] eq "PowerPC_604" |
78
|
|
|
|
|
|
|
) { |
79
|
0
|
|
|
|
|
|
my $uname = getFirstLine(command => 'uname -m'); |
80
|
|
|
|
|
|
|
$cpu->{SPEED} = |
81
|
0
|
0
|
|
|
|
|
$uname =~ /E1D|EAD|C1D|R04|C4D|R4D/ ? 12.2 : |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
82
|
|
|
|
|
|
|
$uname =~ /34M/ ? 133 : |
83
|
|
|
|
|
|
|
$uname =~ /N4D/ ? 150 : |
84
|
|
|
|
|
|
|
$uname =~ /X4M|X4D/ ? 200 : |
85
|
|
|
|
|
|
|
$uname =~ /N4E|K04|K44/ ? 225 : |
86
|
|
|
|
|
|
|
$uname =~ /N4F/ ? 320 : |
87
|
|
|
|
|
|
|
$uname =~ /K45/ ? 360 : |
88
|
|
|
|
|
|
|
undef ; |
89
|
0
|
|
|
|
|
|
last SWITCH; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
0
|
0
|
|
|
|
|
if ($infos[0] eq "PowerPC_RS64_III") { |
93
|
0
|
|
|
|
|
|
$cpu->{SPEED} = 400; |
94
|
0
|
|
|
|
|
|
last SWITCH; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
0
|
0
|
|
|
|
|
if ($infos[0] eq "PowerPC_620") { |
98
|
0
|
|
|
|
|
|
$cpu->{SPEED} = 172; |
99
|
0
|
|
|
|
|
|
last SWITCH; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
0
|
|
|
|
|
|
$cpu->{SPEED} = 225; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
# compute core number from lines number |
107
|
0
|
|
|
|
|
|
$cpu->{CORE} = scalar @lsattr; |
108
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
|
push @cpus, $cpu; |
110
|
|
|
|
|
|
|
} |
111
|
0
|
|
|
|
|
|
close $handle; |
112
|
|
|
|
|
|
|
|
113
|
0
|
|
|
|
|
|
return @cpus; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
1; |