From 2c44eadc82dcd97e4abe6c2c1c32fbf0e8cf114f Mon Sep 17 00:00:00 2001 From: Tigerblue77 <37409593+tigerblue77@users.noreply.github.com> Date: Wed, 18 Dec 2024 18:44:23 +0000 Subject: [PATCH] Moving functions to function.sh and avoiding redeclaration in the loop --- Dell_iDRAC_fan_controller.sh | 6 ------ functions.sh | 4 ++++ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Dell_iDRAC_fan_controller.sh b/Dell_iDRAC_fan_controller.sh index acce4a4..ae3e8b7 100644 --- a/Dell_iDRAC_fan_controller.sh +++ b/Dell_iDRAC_fan_controller.sh @@ -95,12 +95,6 @@ while true; do retrieve_temperatures $IS_EXHAUST_TEMPERATURE_SENSOR_PRESENT $IS_CPU2_TEMPERATURE_SENSOR_PRESENT - # Define functions to check if CPU 1 and CPU 2 temperatures are above the threshold - function CPU1_OVERHEAT() { [ $CPU1_TEMPERATURE -gt $CPU_TEMPERATURE_THRESHOLD ]; } - if $IS_CPU2_TEMPERATURE_SENSOR_PRESENT; then - function CPU2_OVERHEAT() { [ $CPU2_TEMPERATURE -gt $CPU_TEMPERATURE_THRESHOLD ]; } - fi - # Initialize a variable to store the comments displayed when the fan control profile changed COMMENT=" -" # Check if CPU 1 is overheating then apply Dell default dynamic fan control profile if true diff --git a/functions.sh b/functions.sh index ea83d9d..2e4c947 100644 --- a/functions.sh +++ b/functions.sh @@ -114,3 +114,7 @@ function get_Dell_server_model() { SERVER_MODEL=$(echo "$IPMI_FRU_content" | tr -s ' ' | grep "Board Product :" | awk -F ': ' '{print $2}') fi } + +# Define functions to check if CPU 1 and CPU 2 temperatures are above the threshold +function CPU1_OVERHEAT() { [ $CPU1_TEMPERATURE -gt $CPU_TEMPERATURE_THRESHOLD ]; } +function CPU2_OVERHEAT() { [ $CPU2_TEMPERATURE -gt $CPU_TEMPERATURE_THRESHOLD ]; }