line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::Linux::i386::CPU; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
135791895
|
use strict; |
|
2
|
|
|
|
|
18
|
|
|
2
|
|
|
|
|
130
|
|
4
|
2
|
|
|
2
|
|
23
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
138
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
1196
|
use FusionInventory::Agent::Tools; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
397
|
|
7
|
2
|
|
|
2
|
|
1363
|
use FusionInventory::Agent::Tools::Linux; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
204
|
|
8
|
2
|
|
|
2
|
|
1534
|
use FusionInventory::Agent::Tools::Generic; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
1095
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub isEnabled { |
11
|
0
|
|
|
0
|
0
|
0
|
my (%params) = @_; |
12
|
0
|
0
|
|
|
|
0
|
return 0 if $params{no_category}->{cpu}; |
13
|
0
|
|
|
|
|
0
|
return -r '/proc/cpuinfo'; |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub doInventory { |
17
|
0
|
|
|
0
|
0
|
0
|
my (%params) = @_; |
18
|
|
|
|
|
|
|
|
19
|
0
|
|
|
|
|
0
|
my $inventory = $params{inventory}; |
20
|
0
|
|
|
|
|
0
|
my $logger = $params{logger}; |
21
|
|
|
|
|
|
|
|
22
|
0
|
|
|
|
|
0
|
foreach my $cpu (_getCPUs(logger => $logger)) { |
23
|
0
|
|
|
|
|
0
|
$inventory->addEntry( |
24
|
|
|
|
|
|
|
section => 'CPUS', |
25
|
|
|
|
|
|
|
entry => $cpu |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub _getCPUs { |
31
|
7
|
|
|
7
|
|
1813
|
my (%params) = @_; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
my @dmidecodeInfos = $params{dmidecode} ? |
34
|
7
|
50
|
|
|
|
44
|
getCpusFromDmidecode(file => $params{dmidecode}) : |
35
|
|
|
|
|
|
|
getCpusFromDmidecode(); |
36
|
|
|
|
|
|
|
|
37
|
7
|
|
|
|
|
12
|
my $count = 0; |
38
|
7
|
|
|
|
|
10
|
my @cpus; |
39
|
|
|
|
|
|
|
my %seen; |
40
|
|
|
|
|
|
|
|
41
|
7
|
|
|
|
|
35
|
foreach my $logicalCpu (getCPUsFromProc(@_)) { |
42
|
29
|
|
|
|
|
45
|
my $cpuId = $logicalCpu->{'physical id'}; |
43
|
29
|
|
|
|
|
37
|
my ($core, $thread); |
44
|
29
|
100
|
|
|
|
51
|
if (defined $cpuId) { |
45
|
27
|
100
|
|
|
|
82
|
next if $seen{$cpuId}++; |
46
|
6
|
|
|
|
|
9
|
$core = $logicalCpu->{'cpu cores'}; |
47
|
6
|
|
|
|
|
12
|
$thread = $logicalCpu->{'siblings'}; |
48
|
|
|
|
|
|
|
} else { |
49
|
2
|
|
|
|
|
4
|
$cpuId = $count; |
50
|
2
|
|
|
|
|
2
|
$core = 1; |
51
|
2
|
|
|
|
|
3
|
$thread = 1; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
8
|
|
|
|
|
17
|
my $dmidecodeInfo = $dmidecodeInfos[$cpuId]; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
my $cpu = { |
57
|
|
|
|
|
|
|
ARCH => 'i386', |
58
|
|
|
|
|
|
|
MANUFACTURER => getCanonicalManufacturer($logicalCpu->{vendor_id}), |
59
|
|
|
|
|
|
|
STEPPING => $logicalCpu->{'stepping'} || |
60
|
|
|
|
|
|
|
$dmidecodeInfo->{STEPPING}, |
61
|
|
|
|
|
|
|
FAMILYNUMBER => $logicalCpu->{'cpu family'} || |
62
|
|
|
|
|
|
|
$dmidecodeInfo->{FAMILYNUMBER}, |
63
|
|
|
|
|
|
|
MODEL => $logicalCpu->{'model'} || |
64
|
|
|
|
|
|
|
$dmidecodeInfo->{MODEL}, |
65
|
|
|
|
|
|
|
NAME => $logicalCpu->{'model name'}, |
66
|
|
|
|
|
|
|
CORE => $core || $dmidecodeInfo->{CORE}, |
67
|
|
|
|
|
|
|
THREAD => $thread || $dmidecodeInfo->{THREAD} |
68
|
8
|
|
33
|
|
|
34
|
}; |
|
|
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
8
|
100
|
|
|
|
31
|
$cpu->{ID} = $dmidecodeInfo->{ID} if $dmidecodeInfo->{ID}; |
71
|
8
|
50
|
|
|
|
20
|
$cpu->{SERIAL} = $dmidecodeInfo->{SERIAL} if $dmidecodeInfo->{SERIAL}; |
72
|
8
|
100
|
|
|
|
21
|
$cpu->{EXTERNAL_CLOCK} = $dmidecodeInfo->{EXTERNAL_CLOCK} if $dmidecodeInfo->{EXTERNAL_CLOCK}; |
73
|
8
|
100
|
|
|
|
21
|
$cpu->{FAMILYNAME} = $dmidecodeInfo->{FAMILYNAME} if $dmidecodeInfo->{FAMILYNAME}; |
74
|
|
|
|
|
|
|
|
75
|
8
|
50
|
|
|
|
55
|
if ($cpu->{NAME} =~ /([\d\.]+)s*(GHZ)/i) { |
76
|
|
|
|
|
|
|
$cpu->{SPEED} = { |
77
|
|
|
|
|
|
|
ghz => 1000, |
78
|
|
|
|
|
|
|
mhz => 1, |
79
|
8
|
|
|
|
|
57
|
}->{lc($2)} * $1; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
8
|
|
|
|
|
21
|
push @cpus, $cpu; |
83
|
8
|
|
|
|
|
19
|
$count++; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
7
|
|
|
|
|
120
|
return @cpus; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
1; |