--- ocsinventory-agent-2.1.1.orig/lib/Ocsinventory/Agent/Backend/OS/Linux/Archs/i386/CPU.pm 2014-04-25 15:28:30.000000000 +0000 +++ ocsinventory-agent-2.1.1/lib/Ocsinventory/Agent/Backend/OS/Linux/Archs/i386/CPU.pm 2014-04-29 07:26:16.993871895 +0000 @@ -18,12 +18,15 @@ my $cpusocket; my $siblings; my $cpucores; + my $cpuspeed; my $coreid; + $cpucores = 0; open CPUINFO, ") { if (/^vendor_id\s*:\s*(Authentic|Genuine|)(.+)/i) { + $cpucores++; $current->{MANUFACTURER} = $2; $current->{MANUFACTURER} =~ s/(TMx86|TransmetaCPU)/Transmeta/; $current->{MANUFACTURER} =~ s/CyrixInstead/Cyrix/; @@ -31,62 +34,74 @@ } if (/^siblings\s*:\s*(\d+)/i){ - $siblings++; - } - $current->{CURRENT_SPEED} = $1 if /^cpu\sMHz\s*:\s*(\d+)/i; + $siblings++; + } + + $current->{CURRENT_SPEED} = $1 if /^cpu\sMHz\s*:\s*(\d+)/i; $current->{TYPE} = $1 if /^model\sname\s*:\s*(.+)/i; - $current->{L2CACHESIZE} = $1 if /^cache\ssize\s*:\s*(\d+)/i; + $current->{L2CACHESIZE} = $1 if /^cache\ssize\s*:\s*(\d+)/i; } - # /proc/cpuinfo provides real time speed processor. - # Get optimal speed with dmidecode command - # Get also cpu cores with dmidecode command - # Get also voltage information with dmidecode command - @cpu = `dmidecode -t processor`; - for (@cpu){ - if (/Processor\sInformation/i){ - $cpusocket++; - $common->addCPU($current) if ($current->{SPEED}); - } - if (/Current\sSpeed:\s*(.*) (|MHz|GHz)/i){ - $current->{SPEED} = $1; - } - else { - $current->{SPEED} = $1; - } + # /proc/cpuinfo provides real time speed processor. + # Get optimal speed with dmidecode command + # Get also cpu cores with dmidecode command + # Get also voltage information with dmidecode command + @cpu = `dmidecode -t processor`; + $cpuspeed = 0; + $current->{CORES} = 'Unknown'; + for (@cpu){ + if (/Processor\sInformation/i){ + $cpusocket++; + if ($cpuspeed != 0){ + if ( $cpusocket > $cpucores ){ + last; + } + $common->addCPU($current); + $current->{CORES} = 'Unknown'; + $cpuspeed = 0; + } + } + + if (/Current\sSpeed:\s*(.*) (|MHz|GHz)/i){ + $cpuspeed = $1; + $current->{SPEED} = $cpuspeed; + } + if (/Core\sCount:\s*(\d+)/i){ $current->{CORES} = $1; } - else { - $current->{CORES} = 'Unknown'; - } + if (/Voltage:\s*(.*)V/i){ $current->{VOLTAGE} = $1; } - if (/Status:\s*(.*),\s(.*)/i){ + + if (/Status:\s*(.*)/i){ + $current->{CPUSTATUS} = $1; + } + + if (/Status:\s*(.*),\s(.*)/i){ $current->{CPUSTATUS} = $2; } - else { - $current->{CPUSTATUS} = $1; - } + if (/Upgrade:\s*(.*)/i){ $current->{SOCKET} = $1; } + # Is(Are) CPU(s) hyperthreaded? if ($siblings = $current->{CORES}) { - # Hyperthreading is off - $current->{HPT}=0; + # Hyperthreading is off + $current->{HPT}=0; } else { - # Hyperthreading is on - $current->{HPT}=1; + # Hyperthreading is on + $current->{HPT}=1; } $current->{CPUARCH}=$cpuarch; - if ($cpuarch eq "x86_64"){ - $current->{DATA_WIDTH}=64; + if ($cpuarch eq "x86_64"){ + $current->{DATA_WIDTH}=64; } else { - $current->{DATA_WIDTH}=32; + $current->{DATA_WIDTH}=32; } }