From d0f70154bcc60396083d1039992b8c1a94042848 Mon Sep 17 00:00:00 2001 From: Jordi Sanfeliu Date: Wed, 14 Apr 2021 10:35:44 +0200 Subject: [PATCH] added support to get temperature values for gpu[n] keys using the output of 'lmsensors' #320 --- lib/lmsens.pm | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lib/lmsens.pm b/lib/lmsens.pm index 7e71bd2..c2fb98f 100644 --- a/lib/lmsens.pm +++ b/lib/lmsens.pm @@ -311,6 +311,29 @@ sub lmsens_update { lmsens_alerts($config, $str, $value); } } + for($n = 0; $n < 9; $n++) { + $str = "gpu" . $n; + $gpu[$n] = 0 unless $gpu[$n]; + next if !$lmsens->{list}->{$str}; + if($lmsens->{list}->{$str} =~ m/^lmsensors:\S+/) { + my $lmkey = $lmsens->{list}->{$str}; + $lmkey =~ s/^lmsensors://; + if($data[$l] =~ /^$lmkey:/ && $data[$l] !~ /RPM/) { + my (undef, $tmp) = split(':', $data[$l]); + if($tmp eq "\n") { + $l++; + $tmp = $data[$l]; + } + my ($value, undef) = split(' ', $tmp); + if($value =~ m/^\+?(\d{1,3}\.?\d*)/) { + $value = $1; + } + $gpu[$n] = int($value); + # check alerts for each sensor defined + lmsens_alerts($config, $str, $value); + } + } + } } for($n = 0; $n < 9; $n++) { $str = "gpu" . $n;