Fix nan handling of alternative temperature sources.

This commit is contained in:
Andreas Bachlechner 2021-10-11 17:17:28 +02:00
parent 09e2354950
commit 6962da4fe4
1 changed files with 5 additions and 3 deletions

View File

@ -29,6 +29,8 @@ use File::Basename;
use Exporter 'import';
our @EXPORT = qw(disk_init disk_update disk_cgi);
sub isnan { ! defined( $_[0] <=> (0+"inf")) }
sub disk_init {
my $myself = (caller(0))[3];
my ($package, $config, $debug) = @_;
@ -229,7 +231,7 @@ sub disk_update {
}
if(/^190/ && /Airflow_Temperature_Cel/) {
my @tmp = split(' ', $_);
$temp = $tmp[9] unless $temp;
$temp = $tmp[9] unless ($temp && !isnan($temp));
chomp($temp);
}
if(/^197/ && /Current_Pending_Sector/) {
@ -239,12 +241,12 @@ sub disk_update {
}
if(/^Current Drive Temperature: /) {
my @tmp = split(' ', $_);
$temp = $tmp[3] unless $temp;
$temp = $tmp[3] unless ($temp && !isnan($temp));
chomp($temp);
}
if(/^Temperature: /) {
my @tmp = split(' ', $_);
$temp = $tmp[1] unless $temp;
$temp = $tmp[1] unless ($temp && !isnan($temp));
chomp($temp);
}
}