add caching, minor improvements

main
"Riku" 2024-08-13 07:35:18 +03:00
parent 06533ceba4
commit 16ea60a4fb
1 changed files with 15 additions and 11 deletions

View File

@ -16,6 +16,10 @@ use List::Util qw[min max];
`ipmitool sensor thresh FAN4 lower 0 100 200`;
`ipmitool sensor thresh FAN5 lower 0 100 200`;
# cache SDR data for faster access
`rm /opt/ipmi-cache.sdr`;
`while ipmitool sdr dump /opt/ipmi-cache.sdr; [ $? != 0 ]; do sleep 2; done`;
my $min_temp_change = 2; # °C minimum change to actually cause a fan speed update
my $seconds_to_sleep = 2; # Number of seconds to sleep between update loops
@ -54,8 +58,8 @@ my $g_last_set_cpu_temp = 0;
my $g_last_set_sys_temp = 0;
sub UpdateFanSpeed {
# Gather statistics for fan speed and CPU Temp and stuch
my $ipmi_output = `ipmitool sdr list full`;
# Gather statistics for fan speed and CPU Temp
my $ipmi_output = `ipmitool sdr list full -S /opt/ipmi-cache.sdr`;
my @vals = split( "\n", $ipmi_output );
my $current_cpu_temp = 0;