reduce ipmi calls

This commit is contained in:
Kovasky Buezo
2024-04-15 13:30:04 -04:00
parent 6d56ff11cd
commit 85d99c3e56

View File

@ -20,14 +20,16 @@ check_temperature() {
sorted_temps=($(printf "%s\n" "${temp_arr[@]}" | sort -nr))
max_temp=${sorted_temps[0]}
if [ "$max_temp" -le 60 ]; then
if [ "$max_temp" -le 60 ] && [ "$CURRENT_PROFILE" != "MANUAL" ]; then
# enable manual fan control
ipmitool -I lanplus -H "$HOST" -U "$USER" -P "$PASS" raw 0x30 0x30 0x01 0x00 &> /dev/null
# set initial fan to 20%
ipmitool -I lanplus -H "$HOST" -U "$USER" -P "$PASS" raw 0x30 0x30 0x02 0xff 0x14 &> /dev/null
else
CURRENT_PROFILE="MANUAL"
elif [ "$max_temp" -gt 60 ] && [ "$CURRENT_PROFILE" != "AUTO" ]; then
# enable Dell fan control
ipmitool -I lanplus -H "$HOST" -U "$USER" -P "$PASS" raw 0x30 0x30 0x01 0x01 &> /dev/null
CURRENT_PROFILE="AUTO"
fi
}
@ -46,6 +48,7 @@ HOST=""
USER=""
PASS=""
VMID=""
CURRENT_PROFILE=""
start_time=$(ps -o lstart= -p $(cat /var/run/qemu-server/$VMID.pid))
start_time=$(date -d "$start_time" +%s)
@ -59,5 +62,10 @@ disable_third_party_mode
while true; do
check_temperature
sleep 60
if [[ "$CURRENT_PROFILE" == "AUTO" ]]; then
sleep 300
else
sleep 60
fi
done