line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::Win32::CPU; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
71189139
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
86
|
|
4
|
2
|
|
|
2
|
|
24
|
use warnings; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
151
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
19
|
use English qw(-no_match_vars); |
|
2
|
|
|
|
|
71
|
|
|
2
|
|
|
|
|
35
|
|
7
|
2
|
|
|
2
|
|
3183
|
use Win32; |
|
2
|
|
|
|
|
127
|
|
|
2
|
|
|
|
|
30
|
|
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
639
|
use FusionInventory::Agent::Tools; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
392
|
|
10
|
2
|
|
|
2
|
|
1285
|
use FusionInventory::Agent::Tools::Win32; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
216
|
|
11
|
2
|
|
|
2
|
|
1365
|
use FusionInventory::Agent::Tools::Generic; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
1461
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub isEnabled { |
14
|
0
|
|
|
0
|
0
|
0
|
my (%params) = @_; |
15
|
0
|
0
|
|
|
|
0
|
return 0 if $params{no_category}->{cpu}; |
16
|
0
|
|
|
|
|
0
|
return 1; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub doInventory { |
20
|
0
|
|
|
0
|
0
|
0
|
my (%params) = @_; |
21
|
|
|
|
|
|
|
|
22
|
0
|
|
|
|
|
0
|
my $inventory = $params{inventory}; |
23
|
0
|
|
|
|
|
0
|
my $logger = $params{logger}; |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
0
|
my @cpus = _getCPUs($logger); |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
0
|
foreach my $cpu (@cpus) { |
28
|
0
|
|
|
|
|
0
|
$inventory->addEntry( |
29
|
|
|
|
|
|
|
section => 'CPUS', |
30
|
|
|
|
|
|
|
entry => $cpu |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
0
|
0
|
|
0
|
|
0
|
if (any { $_->{NAME} =~ /QEMU/i } @cpus) { |
|
0
|
|
|
|
|
0
|
|
35
|
0
|
|
|
|
|
0
|
$inventory->setHardware ({ |
36
|
|
|
|
|
|
|
VMSYSTEM => 'QEMU' |
37
|
|
|
|
|
|
|
}); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub _getCPUs { |
42
|
5
|
|
|
5
|
|
2390
|
my ($logger) = @_; |
43
|
|
|
|
|
|
|
|
44
|
5
|
100
|
|
|
|
15
|
my @dmidecodeInfos = Win32::GetOSName() eq 'Win2003' ? |
45
|
|
|
|
|
|
|
() : getCpusFromDmidecode(); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# the CPU description in WMI is false, we use the registry instead |
48
|
5
|
|
|
|
|
39
|
my $registryInfos = getRegistryKey( |
49
|
|
|
|
|
|
|
path => "HKEY_LOCAL_MACHINE/Hardware/Description/System/CentralProcessor", |
50
|
|
|
|
|
|
|
logger => $logger |
51
|
|
|
|
|
|
|
); |
52
|
|
|
|
|
|
|
|
53
|
5
|
|
|
|
|
9422
|
my $cpuId = 0; |
54
|
5
|
|
|
|
|
9
|
my @cpus; |
55
|
|
|
|
|
|
|
|
56
|
5
|
|
|
|
|
26
|
foreach my $object (getWMIObjects( |
57
|
|
|
|
|
|
|
class => 'Win32_Processor', |
58
|
|
|
|
|
|
|
properties => [ qw/NumberOfCores NumberOfLogicalProcessors ProcessorId MaxClockSpeed/ ] |
59
|
|
|
|
|
|
|
)) { |
60
|
|
|
|
|
|
|
|
61
|
8
|
|
|
|
|
3256
|
my $dmidecodeInfo = $dmidecodeInfos[$cpuId]; |
62
|
8
|
|
|
|
|
23
|
my $registryInfo = $registryInfos->{"$cpuId/"}; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# Compute WMI threads for this CPU if not available in dmidecode, this is the case on win2003r2 with 932370 hotfix applied (see #2894) |
65
|
8
|
100
|
66
|
|
|
48
|
my $wmi_threads = !$dmidecodeInfo->{THREAD} && $object->{NumberOfCores} ? $object->{NumberOfLogicalProcessors}/$object->{NumberOfCores} : undef; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# Split CPUID from its value inside registry |
68
|
8
|
|
|
|
|
91
|
my @splitted_identifier = split(/ |\n/ ,$registryInfo->{'/Identifier'}); |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
my $cpu = { |
71
|
|
|
|
|
|
|
CORE => $dmidecodeInfo->{CORE} || $object->{NumberOfCores}, |
72
|
|
|
|
|
|
|
THREAD => $dmidecodeInfo->{THREAD} || $wmi_threads, |
73
|
|
|
|
|
|
|
DESCRIPTION => $registryInfo->{'/Identifier'}, |
74
|
|
|
|
|
|
|
NAME => trimWhitespace($registryInfo->{'/ProcessorNameString'}), |
75
|
|
|
|
|
|
|
MANUFACTURER => getCanonicalManufacturer($registryInfo->{'/VendorIdentifier'}), |
76
|
|
|
|
|
|
|
SERIAL => $dmidecodeInfo->{SERIAL}, |
77
|
|
|
|
|
|
|
SPEED => $dmidecodeInfo->{SPEED} || $object->{MaxClockSpeed}, |
78
|
|
|
|
|
|
|
FAMILYNUMBER => $splitted_identifier[2], |
79
|
|
|
|
|
|
|
MODEL => $splitted_identifier[4], |
80
|
|
|
|
|
|
|
STEPPING => $splitted_identifier[6], |
81
|
|
|
|
|
|
|
ID => $dmidecodeInfo->{ID} || $object->{ProcessorId} |
82
|
8
|
|
66
|
|
|
75
|
}; |
|
|
|
100
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
66
|
|
|
|
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# Some information are missing on Win2000 |
85
|
8
|
50
|
|
|
|
27
|
if (!$cpu->{NAME}) { |
86
|
0
|
|
|
|
|
0
|
$cpu->{NAME} = $ENV{PROCESSOR_IDENTIFIER}; |
87
|
0
|
0
|
|
|
|
0
|
if ($cpu->{NAME} =~ s/,\s(\S+)$//) { |
88
|
0
|
|
|
|
|
0
|
$cpu->{MANUFACTURER} = $1; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
8
|
100
|
|
|
|
20
|
if ($cpu->{SERIAL}) { |
93
|
1
|
|
|
|
|
8
|
$cpu->{SERIAL} =~ s/\s//g; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
8
|
100
|
|
|
|
81
|
if ($cpu->{NAME} =~ /([\d\.]+)s*(GHZ)/i) { |
97
|
|
|
|
|
|
|
$cpu->{SPEED} = { |
98
|
|
|
|
|
|
|
ghz => 1000, |
99
|
|
|
|
|
|
|
mhz => 1, |
100
|
6
|
|
|
|
|
46
|
}->{lc($2)} * $1; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
8
|
|
|
|
|
20
|
push @cpus, $cpu; |
104
|
|
|
|
|
|
|
|
105
|
8
|
|
|
|
|
26
|
$cpuId++; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
5
|
|
|
|
|
62
|
return @cpus; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
1; |