Add CPU temp for AMD Ryzen Threadripper #1484

This commit is contained in:
Ilia Rostovtsev
2021-06-23 22:37:17 +03:00
parent 939c8eb4fe
commit 68674ed355

View File

@@ -501,6 +501,7 @@ if (&has_command("sensors")) {
my $aa;
my $ab;
my $ac;
my $ad;
&open_execute_command($fh, "sensors </dev/null 2>/dev/null", 1);
while(<$fh>) {
if (/Core\s+(\d+):\s+([\+\-][0-9\.]+)/) {
@@ -523,10 +524,7 @@ if (&has_command("sensors")) {
/in[\d+]:\s+[\+\-0-9\.]+\s+V/i);
# Get odd output like in #1253
if ($aa && (
/temp(\d+):\s+([\+\-][0-9\.]+)\s+.*?[=+].*?\)/ ||
/temp(\d+):\s+([\+\-][0-9\.]+).*?[Cc]\s+.*?[=+].*?\)/
)) {
if ($aa && /temp(\d+):\s+([\+\-][0-9\.]+)\s+.*?[=+].*?\)/) {
# Adjust to start from `0` as all other outputs
push(@rvx, { 'core' => (int($1) - 1),
'temp' => $2 });
@@ -544,18 +542,23 @@ if (&has_command("sensors")) {
'temp' => $2 });
}
# AMD Ryzen oddness
# AMD Ryzen type #1
$ac = 0 if (/^\s*$/);
# Check for CPU
$ac = 1 if (/[\d]+temp-pci/i);
# Get odd output like in #discussion/600155
if ($ac && /Tdie:\s+([\+\-][0-9\.]+)/) {
push(@rvx, { 'core' => 0,
'temp' => $1 });
}
}
# AMD Ryzen type #2 (Threadripper) #1484
$ad = 0 if (/^\s*$/);
$ad = 1 if (/^k[\d]{2}temp-pci-[\d]{2}c[\d]+/i);
if ($ad && /temp(\d+):\s+([\+\-][0-9\.]+).*?[Cc]\s+.*?[=+].*?\)/) {
push(@rvx, { 'core' => $1,
'temp' => $2 });
}
}
}
close($fh);
}