From 8614648388a976497bdab50c45cae17cea05e347 Mon Sep 17 00:00:00 2001 From: Tim Connors Date: Tue, 18 Nov 2025 00:49:50 +1100 Subject: [PATCH] add raid_controller_battery_temp, and ensure MegaCli doesn't continuously log --- poweredge-fand.conf | 2 +- poweredge-fand.pl | 24 ++++++++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/poweredge-fand.conf b/poweredge-fand.conf index 3ed44fd..90a4882 100755 --- a/poweredge-fand.conf +++ b/poweredge-fand.conf @@ -48,7 +48,7 @@ sub custom_temperature_calculation { # at least one fan speed. Note that drivetemp devices may already # be included via $*_drives averages below. my $gpu = $sensors_ref->{"amdgpu-pci-0400"}{"edge"}{"temp1_input"}; # 0.2*fan3 + 0.5*fan4 + 0.3*fan5 - my $raid_card = raid_controller_temp(); # fan4+fan5; + my $raid_card = max(raid_controller_temp(),raid_controller_battery_temp()); # fan4+fan5; my $left_cpu = $sensors_ref->{"coretemp-isa-0000"}{"Package id 0"}{"temp1_input"}; # fan2; my $right_cpu = $sensors_ref->{"coretemp-isa-0001"}{"Package id 1"}{"temp1_input"}; # fan4; diff --git a/poweredge-fand.pl b/poweredge-fand.pl index f99918a..c38d24d 100755 --- a/poweredge-fand.pl +++ b/poweredge-fand.pl @@ -8,7 +8,6 @@ # background information: # https://www.dell.com/community/PowerEdge-Hardware-General/T130-Fan-Speed-Algorithm/td-p/5052692 # https://serverfault.com/questions/715387/how-do-i-stop-dell-r730xd-fans-from-going-full-speed-when-broadcom-qlogic-netxtr/733064#733064 -# could monitor H710 temperature with sudo env /opt/MegaRAID/MegaCli/MegaCli64 -AdpAllInfo -aALL | grep -i temperature use strict; use warnings; @@ -251,7 +250,7 @@ sub raid_controller_temp { # getting stuck in the D state, holding STDERR open despite a kill # -9, so instead just send it to a tempfile, and read from that # tempfile - system("timeout -k 1 20 /opt/MegaRAID/MegaCli/MegaCli64 -AdpAllInfo -aALL | grep -i ^ROC.temperature | awk '{print \$4}' > $tempfilename"); + system("timeout -k 1 20 /opt/MegaRAID/MegaCli/MegaCli64 -AdpAllInfo -aALL -NoLog | grep -i ^ROC.temperature | awk '{print \$4}' > $tempfilename"); my $val = `cat < $tempfilename`; chomp $val; if ($val ne "") { @@ -263,6 +262,27 @@ sub raid_controller_temp { return $raid_controller_cache_temp; } +my $raid_controller_battery_temp; +my $raid_controller_battery_time; +sub raid_controller_battery_temp { + if (!defined $raid_controller_battery_time or + $raid_controller_battery_time > $raid_controller_poll_interval) { + # could just be a simple pipe, but protect against something + # getting stuck in the D state, holding STDERR open despite a kill + # -9, so instead just send it to a tempfile, and read from that + # tempfile + system("timeout -k 1 20 /opt/MegaRAID/MegaCli/MegaCli64 -AdpBbuCmd -GetBbuStatus -aALL -NoLog | grep -i ^ROC.temperature | awk '{print \$4}' > $tempfilename"); + + my $val = `cat < $tempfilename`; chomp $val; + if ($val ne "") { + $raid_controller_battery_temp = $val; + $raid_controller_battery_time = time; + } + } + + return $raid_controller_battery_temp; +} + my $ambient_cache_temp = 20; my $ambient_cache_time; sub ambient_temp {