Skip to content

Commit

Permalink
dmidecode: ignore CPU frequency if 10>GHz
Browse files Browse the repository at this point in the history
Closes: #633
  • Loading branch information
Gonéri Le Bouder committed May 24, 2012
1 parent 89e52c7 commit cebcb35
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
21 changes: 14 additions & 7 deletions lib/FusionInventory/Agent/Tools/Generic.pm
Expand Up @@ -99,13 +99,20 @@ sub getCpusFromDmidecode {
$cpu->{SPEED} = $1 * 1000;
}
}
if (!$cpu->{SPEED}) {
if ($info->{'Max Speed'}) {
if ($info->{'Max Speed'} =~ /^\s*(\d+)\s*Mhz/i) {
$cpu->{SPEED} = $1;
} elsif ($info->{'Max Speed'} =~ /^\s*(\d+)\s*Ghz/i) {
$cpu->{SPEED} = $1 * 1000;
}
if (!$cpu->{SPEED} && $info->{'Max Speed'}) {
# We only look for 3 digit Mhz frequency to avoid abvious bad
# value like 30000 (#633)
if ($info->{'Max Speed'} =~ /^\s*(\d{3,4})\s*Mhz/i) {
$cpu->{SPEED} = $1;
} elsif ($info->{'Max Speed'} =~ /^\s*(\d+)\s*Ghz/i) {
$cpu->{SPEED} = $1 * 1000;
}
}
if (!$cpu->{SPEED} && $info->{'Current Speed'}) {
if ($info->{'Current Speed'} =~ /^\s*(\d{3,4})\s*Mhz/i) {
$cpu->{SPEED} = $1;
} elsif ($info->{'Current Speed'} =~ /^\s*(\d+)\s*Ghz/i) {
$cpu->{SPEED} = $1 * 1000;
}
}

Expand Down
2 changes: 1 addition & 1 deletion t/tools/generic.t
Expand Up @@ -5894,7 +5894,7 @@ my %cpu_tests = (
{
ID => '42 0F 10 00 FF FB 8B 07',
NAME => undef,
SPEED => '30000',
SPEED => '2300',
THREAD => undef,
SERIAL => undef,
MANUFACTURER => 'AuthenticAMD',
Expand Down

0 comments on commit cebcb35

Please sign in to comment.