From 85d99c3e56ae29d2eeaa75fd78d2c1f2da264171 Mon Sep 17 00:00:00 2001 From: Kovasky Buezo Date: Mon, 15 Apr 2024 13:30:04 -0400 Subject: [PATCH] reduce ipmi calls --- proxmox/fan_control/fan_control.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/proxmox/fan_control/fan_control.sh b/proxmox/fan_control/fan_control.sh index 4c863bd..0627aff 100644 --- a/proxmox/fan_control/fan_control.sh +++ b/proxmox/fan_control/fan_control.sh @@ -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