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