Feature #1597
More precise cpus informations
| Status: | Closed | Start date: | 04/17/2012 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | % Done: | 100% | ||
| Category: | internal | |||
| Target version: | 2.2.1 | |||
| For junior contributor: | No |
Description
Do you think getting more precise informations about processors like family model and stepping values is interesting?
here is a spec about solutions I propose to get those informations.
http://www.rudder-project.org/foswiki/Development/CpusFusion
Associated revisions
History
#1
Updated by Guillaume Rousse about 1 year ago
- Target version set to 2.3.0
#2
Updated by Gonéri Le Bouder about 1 year ago
Can you provide us some example of what you plan to add?
#3
Updated by Vincent Membré about 1 year ago
With what I plan, On my machine cpu reports should look like
<CPUS>
<CORE>4</CORE>
<EXTERNAL_CLOCK>100</EXTERNAL_CLOCK>
<FAMILY><NAME>Other</NAME>
<NUMBER>6</NUMBER></FAMILY>
<ID>A7 06 02 00 FF FB EB BF</ID>
<MANUFACTURER>Intel</MANUFACTURER>
<MODEL>42</MODEL>
<NAME>Intel(R) Core(TM) i5-2400 CPU @ 3.10GHz</NAME>
<SPEED>3100</SPEED>
<STEPPING>7</STEPPING>
<THREAD>1</THREAD></CPUS>
I would add those fields, either by using dmidecode or computing cpuid
<FAMILY>
<NAME>Other</NAME>
<NUMBER>6</NUMBER>
</FAMILY>
<MODEL>42</MODEL>
<STEPPING>7</STEPPING>
I found that having a family field with subfields for name and number easier to read, but having two fields family_number and family_name may be easier to handle with.
#4
Updated by Gonéri Le Bouder about 1 year ago
What is the FAMILY_NUMBER exactly? Can you show up an example?
For you informtion we already the inventory of the CPUID ( http://en.wikipedia.org/wiki/CPUID ) that can be useful to identify a given CPU.
#5
Updated by Vincent Membré about 1 year ago
FAMILY_NUMBER can be found in CPUID.
It's the 4th hexadecimal number in CPUID
(in mine : A7 0*6* 02 00 FF FB EB BF)
I'm already using the CPUID you have determined to get those informations.
In case CPUID is missing (ie : in VMs) stepping, model and family number can be obtained through /proc/cpuinfo
#6
Updated by Vincent Membré about 1 year ago
Here is a patch to get expected behavior.
I've done test file too, but haven't include it here!
diff --git a/lib/FusionInventory/Agent/Task/Inventory/Input/Linux/Archs/i386.pm b/lib/FusionInventory/Agent/Task/Inventory/Input/Linux/Archs/i386.pm
index f9f84b9..2ac3643 100644
--- a/lib/FusionInventory/Agent/Task/Inventory/Input/Linux/Archs/i386.pm
+++ b/lib/FusionInventory/Agent/Task/Inventory/Input/Linux/Archs/i386.pm
@@ -52,6 +52,23 @@ sub doInventory {
if (!$cpu->{THREAD}) {
$cpu->{THREAD} = $procList->[$cpt]{THREAD};
}
+ # determine stepping family and model number depends on cpuid
+ if ($cpu->{ID}) {
+
+ # Split CPUID to get access to its content
+ my @id = split ("",$cpu->{ID});
+ # convert hexadecimal value
+ $cpu->{STEPPING} = hex $id[1];
+ # family number is composed of 3 hexadecimal number
+ $cpu->{FAMILYNUMBER} = hex $id[9].$id[10].$id[4];
+ $cpu->{MODEL} = hex $id[7].$id[0];
+ }
+ else {
+ # Get directly informations from cpuinfo
+ $cpu->{STEPPING} = $proc_cpu->{'stepping'};
+ $cpu->{FAMILYNUMBER} =$proc_cpu->{'cpu family'};
+ $cpu->{MODEL} = $proc_cpu->{'model'};
+ }
if ($cpu->{NAME} =~ /([\d\.]+)s*(GHZ)/i) {
$cpu->{SPEED} = {
ghz => 1000,
diff --git a/lib/FusionInventory/Agent/Task/Inventory/Input/MacOS/CPU.pm b/lib/FusionInventory/Agent/Task/Inventory/Input/MacOS/CPU.pm
index ad083c2..4e5aafb 100644
--- a/lib/FusionInventory/Agent/Task/Inventory/Input/MacOS/CPU.pm
+++ b/lib/FusionInventory/Agent/Task/Inventory/Input/MacOS/CPU.pm
@@ -7,20 +7,35 @@ use FusionInventory::Agent::Tools;
sub isEnabled {
return
- -r '/usr/sbin/system_profiler' &&
- canLoad("Mac::SysProfile");
+ -r '/usr/sbin/system_profiler';
}
sub doInventory {
my (%params) = @_;
my $inventory = $params{inventory};
+ my $logger = $params{logger};
+
+ # System profiler informations
+ my $infos = getSystemProfilerInfos(@_);
+
+ # Get more informations from sysctl
+ my $handle = getFileHandle (
+ logger => $logger,
+ command => 'sysctl -a machdep.cpu'
+ );
+
+
+ # add sysctl informations into profiler informations
+ my $info = $infos->{'Hardware Overview'}
+ while (my $line = <$handle>) {
+ chomp $line;
+ if ($line =~ /(.+) : \s (.+)/x) {
+ $info->{$1}=$2;
+ }
+ }
- my $prof = Mac::SysProfile->new();
- my $info = $prof->gettype('SPHardwareDataType');
- return unless ref $info eq 'HASH';
- $info = $info->{'Hardware Overview'};
my $type = $info->{'Processor Name'} ||
$info->{'CPU Type'};
@@ -29,9 +44,15 @@ sub doInventory {
1;
my $speed = $info->{'Processor Speed'} ||
$info->{'CPU Speed'};
+
+ my $stepping = $info->{'machdep.cpu.stepping'};
+
+ my $family = $info->{'machdep.cpu.family'};
+
+ my $model = $info->{'machdep.cpu.model'};
+
# French Mac returns 2,60 Ghz instead of 2.60 Ghz :D
$speed =~ s/,/./;
-
if ($speed =~ /GHz$/i) {
$speed =~ s/GHz//i;
$speed = $speed * 1000;
@@ -57,6 +78,9 @@ sub doInventory {
MANUFACTURER => $manufacturer,
NAME => $type,
THREAD => 1,
+ FAMILYNUMBER => $family,
+ MODEL => $model,
+ STEPPING => $stepping,
SPEED => $speed
}
);
diff --git a/lib/FusionInventory/Agent/Task/Inventory/Input/Win32/CPU.pm b/lib/FusionInventory/Agent/Task/Inventory/Input/Win32/CPU.pm
index 768d796..08815e6 100644
--- a/lib/FusionInventory/Agent/Task/Inventory/Input/Win32/CPU.pm
+++ b/lib/FusionInventory/Agent/Task/Inventory/Input/Win32/CPU.pm
@@ -56,6 +56,9 @@ sub _getCPUs {
my $dmidecodeInfo = $dmidecodeInfos[$cpuId];
my $registryInfo = $registryInfos->{"$cpuId/"};
+ # Split CPUID from its value inside registry
+ my @splitted_identifier = split(/ |\n/ ,$registryInfo->{'/Identifier'});
+
my $cpu = {
CORE => $dmidecodeInfo->{CORE} || $object->{NumberOfCores},
THREAD => $dmidecodeInfo->{THREAD},
@@ -64,6 +67,9 @@ sub _getCPUs {
MANUFACTURER => $registryInfo->{'/VendorIdentifier'},
SERIAL => $dmidecodeInfo->{SERIAL},
SPEED => $dmidecodeInfo->{SPEED} || $object->{MaxClockSpeed},
+ FAMILYNUMBER => $splitted_identifier[2],
+ MODEL => $splitted_identifier[4],
+ STEPPING => $splitted_identifier[6],
ID => $dmidecodeInfo->{ID} || $object->{ProcessorId}
};
diff --git a/lib/FusionInventory/Agent/Task/Inventory/Inventory.pm b/lib/FusionInventory/Agent/Task/Inventory/Inventory.pm
index 6db1ae9..b4bc384 100644
--- a/lib/FusionInventory/Agent/Task/Inventory/Inventory.pm
+++ b/lib/FusionInventory/Agent/Task/Inventory/Inventory.pm
@@ -18,7 +18,7 @@ my %fields = (
CONTROLLERS => [ qw/CAPTION DRIVER NAME MANUFACTURER PCICLASS PCIID
PCISUBSYSTEMID PCISLOT TYPE REV/ ],
CPUS => [ qw/CACHE CORE DESCRIPTION MANUFACTURER NAME THREAD SERIAL
- SPEED ID EXTERNAL_CLOCK/ ],
+ STEPPING FAMILYNAME FAMILYNUMBER MODEL SPEED ID EXTERNAL_CLOCK/ ],
DRIVES => [ qw/CREATEDATE DESCRIPTION FREE FILESYSTEM LABEL LETTER
SERIAL SYSTEMDRIVE TOTAL TYPE VOLUMN/ ],
ENVS => [ qw/KEY VAL/ ],
diff --git a/lib/FusionInventory/Agent/Tools/Generic.pm b/lib/FusionInventory/Agent/Tools/Generic.pm
index 825b70a..c91d2dc 100644
--- a/lib/FusionInventory/Agent/Tools/Generic.pm
+++ b/lib/FusionInventory/Agent/Tools/Generic.pm
@@ -80,10 +80,11 @@ sub getCpusFromDmidecode {
($proc_version && $proc_version eq '00000000000000000000000000000000');
my $cpu = {
- SERIAL => $info->{'Serial Number'},
- ID => $info->{ID},
- CORE => $info->{'Core Count'} || $info->{'Core Enabled'},
- THREAD => $info->{'Thread Count'},
+ SERIAL => $info->{'Serial Number'},
+ ID => $info->{ID},
+ CORE => $info->{'Core Count'} || $info->{'Core Enabled'},
+ THREAD => $info->{'Thread Count'},
+ FAMILYNAME => $info->{'Family'}
};
$cpu->{MANUFACTURER} = $info->{'Manufacturer'} || $info->{'Processor Manufacturer'};
$cpu->{NAME} =
#7
Updated by Vincent Membré about 1 year ago
It can be easier to read from my repository : https://github.com/VinceMacBuche/fusioninventory-agent/compare/2.2.x...cpupatch
plus there's test modifications there.
What do you think about it?
#8
Updated by Gonéri Le Bouder about 1 year ago
- Category set to internal
- Status changed from New to In Progress
Looks good for me. We will need to patch the test-suite.
#9
Updated by Guillaume Rousse about 1 year ago
#10
Updated by Vincent Membré about 1 year ago
- File cpu.patch added
patch is almost complete,
with code, tests and docs
you can see it on the link above
and there's patch here too
#11
Updated by Vincent Membré about 1 year ago
- File deleted (
cpu.patch)
#12
Updated by Vincent Membré about 1 year ago
- File cpu_withdoc.patch
added
forgot documentation... fixed!
#13
Updated by Gonéri Le Bouder about 1 year ago
- File 0001-extend-CPU-information.patch
added - Assignee set to Vincent Membré
- Target version changed from 2.3.0 to 2.2.1
I rebased the serie in a sole commit. I attach the patch.
For your information, a valid git commit message should have this format
-----------------------------8<----------
50 characters to give a short description of the patch (like a mail subject)
(an empty line)
The commit message itself with 72 caracters line. (like a mail body)
----------------------------->8----------
http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
#14
Updated by Vincent Membré about 1 year ago
- Status changed from In Progress to Closed
- % Done changed from 0 to 100
Applied in changeset ae38059a50a57940ba72dabafea962373eb066b4.