Add support for AMD CPU thermisters #1714

This commit is contained in:
iliajie
2022-08-13 20:45:54 +03:00
parent c84c755dd7
commit cf5568ea1d

View File

@@ -496,11 +496,13 @@ sub get_current_cpu_data
{
my @cpu;
my @fans;
my @cputhermisters;
if (&has_command("sensors")) {
my ($cpu, $cpu_aux, $cpu_package, $cpu_broadcom, $cpu_amd);
my $fh = "SENSORS";
# Examples https://gist.github.com/547451c9ca376b2d18f9bb8d3748276c
# &open_execute_command($fh, "cat /tmp/.webmin/sensors </dev/null 2>/dev/null", 1);
&open_execute_command($fh, "sensors </dev/null 2>/dev/null", 1);
while (<$fh>) {
@@ -517,6 +519,15 @@ if (&has_command("sensors")) {
}
) if ($cpu_fan_num);
# AMD CPU Thermisters #1714
if ($cpu && /thermistor\s+[\d]+:\s+[+-]([\d]+)/i) {
my $temp = int($1);
push(@cputhermisters,
{ 'core' => scalar(@cputhermisters) + 1,
'temp' => $temp
}) if ($temp);
}
# CPU package
($cpu_package) = $_ =~ /(?|(package\s+id\s+[\d]+)|(coretemp-[a-z]+-[\d]+))/i
if (!$cpu_package);
@@ -549,7 +560,7 @@ if (&has_command("sensors")) {
# Non-standard outputs
else {
# Auxiliary CPU temperature and fans were already captured
# Auxiliary CPU temperature and fans were already captured
next if ($cpu_aux);
# CPU types
@@ -628,6 +639,8 @@ if (&has_command("sensors")) {
}
close($fh);
}
@cpu = @cputhermisters
if (!@cpu && @cputhermisters);
return (\@cpu, \@fans);
}