| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::Solaris::CPU; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
100532034
|
use strict; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
63
|
|
|
4
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
80
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
7
|
use English qw(-no_match_vars); |
|
|
2
|
|
|
|
|
35
|
|
|
|
2
|
|
|
|
|
24
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
1287
|
use FusionInventory::Agent::Tools; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
237
|
|
|
9
|
2
|
|
|
2
|
|
719
|
use FusionInventory::Agent::Tools::Solaris; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
1596
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub isEnabled { |
|
12
|
0
|
|
|
0
|
0
|
0
|
my (%params) = @_; |
|
13
|
0
|
0
|
|
|
|
0
|
return 0 if $params{no_category}->{cpu}; |
|
14
|
0
|
|
|
|
|
0
|
return 1; |
|
15
|
|
|
|
|
|
|
} |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub doInventory { |
|
18
|
0
|
|
|
0
|
0
|
0
|
my (%params) = @_; |
|
19
|
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
0
|
my $inventory = $params{inventory}; |
|
21
|
|
|
|
|
|
|
|
|
22
|
0
|
|
|
|
|
0
|
foreach my $cpu (_getCPUs()) { |
|
23
|
0
|
|
|
|
|
0
|
$inventory->addEntry( |
|
24
|
|
|
|
|
|
|
section => 'CPUS', |
|
25
|
|
|
|
|
|
|
entry => $cpu |
|
26
|
|
|
|
|
|
|
); |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _getCPUs { |
|
32
|
13
|
|
|
13
|
|
7070
|
my (%params) = @_; |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# get virtual CPUs from psrinfo -v |
|
35
|
13
|
|
|
|
|
32
|
my @all_virtual_cpus = _getVirtualCPUs(logger => $params{logger}); |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# get physical CPUs from psrinfo -vp |
|
38
|
13
|
|
|
|
|
55
|
my @all_physical_cpus = _getPhysicalCPUs(logger => $params{logger}); |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# count the different speed values |
|
41
|
|
|
|
|
|
|
# undef is temporarily mapped to 0, to avoid warnings |
|
42
|
|
|
|
|
|
|
my @physical_speeds = |
|
43
|
14
|
100
|
|
|
|
34
|
map { $_ ? $_ : undef } |
|
44
|
1
|
|
|
|
|
4
|
sort { $a <=> $b } |
|
45
|
|
|
|
|
|
|
uniq |
|
46
|
13
|
100
|
|
|
|
24
|
map { $_->{speed} || 0 } |
|
|
44
|
|
|
|
|
104
|
|
|
47
|
|
|
|
|
|
|
@all_physical_cpus; |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
my @virtual_speeds = |
|
50
|
14
|
50
|
|
|
|
30
|
map { $_ ? $_ : undef } |
|
51
|
1
|
|
|
|
|
2
|
sort { $a <=> $b } |
|
52
|
|
|
|
|
|
|
uniq |
|
53
|
13
|
50
|
|
|
|
18
|
map { $_->{speed} || 0 } |
|
|
190
|
|
|
|
|
286
|
|
|
54
|
|
|
|
|
|
|
@all_virtual_cpus; |
|
55
|
|
|
|
|
|
|
|
|
56
|
13
|
|
|
|
|
20
|
my @cpus; |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# process CPUs by groups, according to their speed |
|
59
|
13
|
|
|
|
|
27
|
while (@physical_speeds) { |
|
60
|
14
|
|
|
|
|
17
|
my $physical_speed = shift @physical_speeds; |
|
61
|
14
|
|
|
|
|
13
|
my $virtual_speed = shift @virtual_speeds; |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
my @physical_cpus = $physical_speed ? |
|
64
|
50
|
|
|
|
|
52
|
grep { $_->{speed} eq $physical_speed } @all_physical_cpus: |
|
65
|
14
|
100
|
|
|
|
19
|
grep { ! defined $_->{speed} } @all_physical_cpus; |
|
|
6
|
|
|
|
|
9
|
|
|
66
|
|
|
|
|
|
|
my @virtual_cpus = $virtual_speed ? |
|
67
|
210
|
|
|
|
|
193
|
grep { $_->{speed} eq $virtual_speed } @all_virtual_cpus: |
|
68
|
14
|
50
|
|
|
|
23
|
grep { ! defined $_->{speed} } @all_virtual_cpus; |
|
|
0
|
|
|
|
|
0
|
|
|
69
|
|
|
|
|
|
|
|
|
70
|
14
|
|
66
|
|
|
30
|
my $speed = $physical_cpus[0]->{speed} || $virtual_cpus[0]->{speed}; |
|
71
|
14
|
|
33
|
|
|
23
|
my $type = $physical_cpus[0]->{type} || $virtual_cpus[0]->{type}; |
|
72
|
14
|
100
|
|
|
|
33
|
my $manufacturer = |
|
|
|
100
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
$type =~ /SPARC/ ? 'SPARC' : |
|
74
|
|
|
|
|
|
|
$type =~ /Xeon/ ? 'Intel' : |
|
75
|
|
|
|
|
|
|
undef ; |
|
76
|
14
|
|
|
|
|
12
|
my $cpus = scalar @physical_cpus; |
|
77
|
|
|
|
|
|
|
|
|
78
|
14
|
50
|
|
|
|
53
|
my ($cores, $threads) = |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
$type eq 'UltraSPARC-IV' ? (2, 1) : # US-IV & US-IV+ |
|
80
|
|
|
|
|
|
|
$type eq 'UltraSPARC-T1' ? (undef, 4) : # Niagara |
|
81
|
|
|
|
|
|
|
$type eq 'UltraSPARC-T2' ? (undef, 8) : # Niagara-II |
|
82
|
|
|
|
|
|
|
$type eq 'UltraSPARC-T2+' ? (undef, 8) : # Victoria Falls |
|
83
|
|
|
|
|
|
|
$type eq 'SPARC-T3' ? (undef, 8) : # Rainbow Falls |
|
84
|
|
|
|
|
|
|
$type eq 'SPARC64-VI' ? (2, 2) : # Olympus-C SPARC64-VI |
|
85
|
|
|
|
|
|
|
$type eq 'SPARC64-VII' ? (4, 2) : # Jupiter SPARC64-VII |
|
86
|
|
|
|
|
|
|
$type eq 'SPARC64-VII+' ? (4, 2) : # Jupiter+ SPARC64-VII+ |
|
87
|
|
|
|
|
|
|
$type eq 'SPARC64-VII++' ? (4, 2) : # Jupiter++ SPARC64-VII++ |
|
88
|
|
|
|
|
|
|
$type eq 'SPARC64-VIII' ? (8, 2) : # Venus SPARC64-VIII |
|
89
|
|
|
|
|
|
|
(1, 1) ; |
|
90
|
|
|
|
|
|
|
|
|
91
|
14
|
50
|
|
|
|
53
|
if ($type =~ /MB86907/) { |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
0
|
$type = "TurboSPARC-II $type"; |
|
93
|
|
|
|
|
|
|
} elsif ($type =~ /MB86904|390S10/) { |
|
94
|
0
|
0
|
|
|
|
0
|
$type = ($speed > 70) ? "microSPARC-II $type" : "microSPARC $type"; |
|
95
|
|
|
|
|
|
|
} elsif ($type =~ /,RT62[56]/) { |
|
96
|
0
|
|
|
|
|
0
|
$type = "hyperSPARC $type"; |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
# deduce core numbers from number of virtual cpus if needed |
|
100
|
14
|
100
|
|
|
|
20
|
if (!$cores) { |
|
101
|
|
|
|
|
|
|
# cores may be < 1 in case of virtualisation |
|
102
|
6
|
|
|
|
|
13
|
$cores = (scalar @virtual_cpus) / $threads / $cpus; |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
|
|
105
|
14
|
|
|
|
|
25
|
for my $i (1 .. $cpus) { |
|
106
|
44
|
|
|
|
|
129
|
push @cpus, |
|
107
|
|
|
|
|
|
|
{ |
|
108
|
|
|
|
|
|
|
MANUFACTURER => $manufacturer, |
|
109
|
|
|
|
|
|
|
NAME => $type, |
|
110
|
|
|
|
|
|
|
SPEED => $speed, |
|
111
|
|
|
|
|
|
|
CORE => $cores, |
|
112
|
|
|
|
|
|
|
THREAD => $threads |
|
113
|
|
|
|
|
|
|
}; |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
} |
|
116
|
|
|
|
|
|
|
|
|
117
|
13
|
|
|
|
|
97
|
return @cpus; |
|
118
|
|
|
|
|
|
|
} |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub _getVirtualCPUs { |
|
121
|
26
|
|
|
26
|
|
98712
|
my %params = ( |
|
122
|
|
|
|
|
|
|
command => '/usr/sbin/psrinfo -v', |
|
123
|
|
|
|
|
|
|
@_ |
|
124
|
|
|
|
|
|
|
); |
|
125
|
|
|
|
|
|
|
|
|
126
|
26
|
|
|
|
|
85
|
my $handle = getFileHandle(%params); |
|
127
|
26
|
50
|
|
|
|
50
|
return unless $handle; |
|
128
|
|
|
|
|
|
|
|
|
129
|
26
|
|
|
|
|
22
|
my @cpus; |
|
130
|
26
|
|
|
|
|
385
|
while (my $line = <$handle>) { |
|
131
|
1520
|
100
|
|
|
|
3117
|
if ($line =~ /The (\S+) processor operates at (\d+) MHz/) { |
|
132
|
380
|
|
|
|
|
745
|
push @cpus, { |
|
133
|
|
|
|
|
|
|
type => $1, |
|
134
|
|
|
|
|
|
|
speed => $2, |
|
135
|
|
|
|
|
|
|
}; |
|
136
|
380
|
|
|
|
|
647
|
next; |
|
137
|
|
|
|
|
|
|
} |
|
138
|
|
|
|
|
|
|
} |
|
139
|
26
|
|
|
|
|
150
|
close $handle; |
|
140
|
|
|
|
|
|
|
|
|
141
|
26
|
|
|
|
|
145
|
return @cpus; |
|
142
|
|
|
|
|
|
|
} |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub _getPhysicalCPUs { |
|
145
|
26
|
|
|
26
|
|
46041
|
my %params = ( |
|
146
|
|
|
|
|
|
|
command => '/usr/sbin/psrinfo -vp', |
|
147
|
|
|
|
|
|
|
@_ |
|
148
|
|
|
|
|
|
|
); |
|
149
|
|
|
|
|
|
|
|
|
150
|
26
|
|
|
|
|
92
|
my $handle = getFileHandle(%params); |
|
151
|
26
|
50
|
|
|
|
53
|
return unless $handle; |
|
152
|
|
|
|
|
|
|
|
|
153
|
26
|
|
|
|
|
18
|
my @cpus; |
|
154
|
26
|
|
|
|
|
229
|
while (my $line = <$handle>) { |
|
155
|
|
|
|
|
|
|
|
|
156
|
198
|
100
|
|
|
|
342
|
if ($line =~ /^The physical processor has (\d+) virtual/) { |
|
157
|
74
|
|
|
|
|
127
|
push @cpus, { |
|
158
|
|
|
|
|
|
|
count => $1 |
|
159
|
|
|
|
|
|
|
}; |
|
160
|
74
|
|
|
|
|
147
|
next; |
|
161
|
|
|
|
|
|
|
} |
|
162
|
|
|
|
|
|
|
|
|
163
|
124
|
100
|
|
|
|
147
|
if ($line =~ /^The physical processor has (\d+) cores and (\d+) virtual/) { |
|
164
|
2
|
|
|
|
|
8
|
push @cpus, { |
|
165
|
|
|
|
|
|
|
count => $2 |
|
166
|
|
|
|
|
|
|
}; |
|
167
|
2
|
|
|
|
|
5
|
next; |
|
168
|
|
|
|
|
|
|
} |
|
169
|
|
|
|
|
|
|
|
|
170
|
122
|
100
|
|
|
|
171
|
if ($line =~ /^The (\S+) physical processor has (\d+) virtual/) { |
|
171
|
12
|
|
|
|
|
31
|
push @cpus, { |
|
172
|
|
|
|
|
|
|
type => $1, |
|
173
|
|
|
|
|
|
|
count => $2 |
|
174
|
|
|
|
|
|
|
}; |
|
175
|
12
|
|
|
|
|
29
|
next; |
|
176
|
|
|
|
|
|
|
} |
|
177
|
|
|
|
|
|
|
|
|
178
|
110
|
100
|
|
|
|
250
|
if ($line =~ /(\S+) \(.* clock (\d+) MHz\)/) { |
|
179
|
76
|
|
|
|
|
55
|
my $cpu = $cpus[-1]; |
|
180
|
76
|
|
|
|
|
102
|
$cpu->{type} = $1; |
|
181
|
76
|
|
|
|
|
65
|
$cpu->{speed} = $2; |
|
182
|
76
|
|
|
|
|
178
|
next; |
|
183
|
|
|
|
|
|
|
} |
|
184
|
|
|
|
|
|
|
|
|
185
|
34
|
100
|
|
|
|
82
|
if ($line =~ /Intel\(r\) Xeon\(r\) CPU +(\S+)/) { |
|
186
|
16
|
|
|
|
|
11
|
my $cpu = $cpus[-1]; |
|
187
|
16
|
|
|
|
|
53
|
$cpu->{type} = "Xeon $1"; |
|
188
|
|
|
|
|
|
|
} |
|
189
|
|
|
|
|
|
|
} |
|
190
|
26
|
|
|
|
|
116
|
close $handle; |
|
191
|
|
|
|
|
|
|
|
|
192
|
26
|
|
|
|
|
106
|
return @cpus; |
|
193
|
|
|
|
|
|
|
} |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
1; |