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