From 2a5a8a03fcf06c7af9955845aa67b7c51cf95564 Mon Sep 17 00:00:00 2001 From: Tigerblue77 <37409593+tigerblue77@users.noreply.github.com> Date: Sun, 10 Nov 2024 20:28:44 +0100 Subject: [PATCH] Reduced tests occurence to improve performances --- Dell_iDRAC_fan_controller.sh | 24 ++++++++++++++++-------- functions.sh | 32 ++++++-------------------------- 2 files changed, 22 insertions(+), 34 deletions(-) diff --git a/Dell_iDRAC_fan_controller.sh b/Dell_iDRAC_fan_controller.sh index ee82949..e95a264 100644 --- a/Dell_iDRAC_fan_controller.sh +++ b/Dell_iDRAC_fan_controller.sh @@ -50,8 +50,12 @@ fi if [[ $SERVER_MODEL =~ .*[RT][[:space:]]?[0-9][4-9]0.* ]] then DELL_POWEREDGE_GEN_14_OR_NEWER=true + CPU1_TEMPERATURE_INDEX=2 + CPU2_TEMPERATURE_INDEX=4 else DELL_POWEREDGE_GEN_14_OR_NEWER=false + CPU1_TEMPERATURE_INDEX=1 + CPU2_TEMPERATURE_INDEX=2 fi # Log main informations @@ -146,15 +150,19 @@ while true; do fi fi - # Enable or disable, depending on the user's choice, third-party PCIe card Dell default cooling response - # No comment will be displayed on the change of this parameter since it is not related to the temperature of any device (CPU, GPU, etc...) but only to the settings made by the user when launching this Docker container - if $DISABLE_THIRD_PARTY_PCIE_CARD_DELL_DEFAULT_COOLING_RESPONSE + # If server model is Gen 14 (*40) or newer + if ! $DELL_POWEREDGE_GEN_14_OR_NEWER then - disable_third_party_PCIe_card_Dell_default_cooling_response - THIRD_PARTY_PCIE_CARD_DELL_DEFAULT_COOLING_RESPONSE_STATUS="Disabled" - else - enable_third_party_PCIe_card_Dell_default_cooling_response - THIRD_PARTY_PCIE_CARD_DELL_DEFAULT_COOLING_RESPONSE_STATUS="Enabled" + # Enable or disable, depending on the user's choice, third-party PCIe card Dell default cooling response + # No comment will be displayed on the change of this parameter since it is not related to the temperature of any device (CPU, GPU, etc...) but only to the settings made by the user when launching this Docker container + if $DISABLE_THIRD_PARTY_PCIE_CARD_DELL_DEFAULT_COOLING_RESPONSE + then + disable_third_party_PCIe_card_Dell_default_cooling_response + THIRD_PARTY_PCIE_CARD_DELL_DEFAULT_COOLING_RESPONSE_STATUS="Disabled" + else + enable_third_party_PCIe_card_Dell_default_cooling_response + THIRD_PARTY_PCIE_CARD_DELL_DEFAULT_COOLING_RESPONSE_STATUS="Enabled" + fi fi # Print temperatures, active fan control profile and comment if any change happened during last time interval diff --git a/functions.sh b/functions.sh index 7d5922e..1ab29ed 100644 --- a/functions.sh +++ b/functions.sh @@ -38,24 +38,10 @@ function retrieve_temperatures () { # Parse CPU data local CPU_DATA=$(echo "$DATA" | grep "3\." | grep -Po '\d{2}') - if $DELL_POWEREDGE_GEN_14_OR_NEWER - then - # 14 Gen server or newer - CPU1_TEMPERATURE=$(echo $CPU_DATA | awk '{print $2;}') - else - # 13 Gen server or older - CPU1_TEMPERATURE=$(echo $CPU_DATA | awk '{print $1;}') - fi + CPU1_TEMPERATURE=$(echo $CPU_DATA | awk "{print \$$CPU1_TEMPERATURE_INDEX;}") if $IS_CPU2_TEMPERATURE_SENSOR_PRESENT then - if $DELL_POWEREDGE_GEN_14_OR_NEWER - then - # 14 Gen server or newer - CPU2_TEMPERATURE=$(echo $CPU_DATA | awk '{print $4;}') - else - # 13 Gen server or older - CPU2_TEMPERATURE=$(echo $CPU_DATA | awk '{print $2;}') - fi + CPU2_TEMPERATURE=$(echo $CPU_DATA | awk "{print \$$CPU2_TEMPERATURE_INDEX;}") else CPU2_TEMPERATURE="-" fi @@ -72,22 +58,16 @@ function retrieve_temperatures () { fi } +# /!\ Use this function only for Gen 13 and older generation servers /!\ function enable_third_party_PCIe_card_Dell_default_cooling_response () { # We could check the current cooling response before applying but it's not very useful so let's skip the test and apply directly - if ! $DELL_POWEREDGE_GEN_14_OR_NEWER - then - # 13 Gen server or older - ipmitool -I $IDRAC_LOGIN_STRING raw 0x30 0xce 0x00 0x16 0x05 0x00 0x00 0x00 0x05 0x00 0x00 0x00 0x00 > /dev/null - fi + ipmitool -I $IDRAC_LOGIN_STRING raw 0x30 0xce 0x00 0x16 0x05 0x00 0x00 0x00 0x05 0x00 0x00 0x00 0x00 > /dev/null } +# /!\ Use this function only for Gen 13 and older generation servers /!\ function disable_third_party_PCIe_card_Dell_default_cooling_response () { # We could check the current cooling response before applying but it's not very useful so let's skip the test and apply directly - if ! $DELL_POWEREDGE_GEN_14_OR_NEWER - then - # 13 Gen server or older - ipmitool -I $IDRAC_LOGIN_STRING raw 0x30 0xce 0x00 0x16 0x05 0x00 0x00 0x00 0x05 0x00 0x01 0x00 0x00 > /dev/null - fi + ipmitool -I $IDRAC_LOGIN_STRING raw 0x30 0xce 0x00 0x16 0x05 0x00 0x00 0x00 0x05 0x00 0x01 0x00 0x00 > /dev/null } # Returns :