Prepared output for 4 CPU support
Some checks failed
Docker image CI / Build and publish Docker image to Docker Hub and GitHub Containers Repository (push) Has been cancelled

This commit is contained in:
Tigerblue77 2025-11-09 21:50:26 +00:00
parent b613d03146
commit f599f94c6d
2 changed files with 80 additions and 4 deletions

View file

@ -73,6 +73,10 @@ if ! $IS_EXHAUST_TEMPERATURE_SENSOR_PRESENT || ! $IS_CPU2_TEMPERATURE_SENSOR_PRE
echo ""
fi
#readonly NUMBER_OF_DETECTED_CPUS=(${CPUS_TEMPERATURES//;/ })
# TODO : write "X CPU sensors detected." and remove previous ifs
readonly HEADER=$(build_header $NUMBER_OF_DETECTED_CPUS)
# Start monitoring
while true; do
# Sleep for the specified interval before taking another reading
@ -131,11 +135,10 @@ while true; do
# Print temperatures, active fan control profile and comment if any change happened during last time interval
if [ $TABLE_HEADER_PRINT_COUNTER -eq $TABLE_HEADER_PRINT_INTERVAL ]; then
echo " ------- Temperatures -------"
echo " Date & time Inlet CPU 1 CPU 2 Exhaust Active fan speed profile Third-party PCIe card Dell default cooling response Comment"
printf "%s\n" "$HEADER"
TABLE_HEADER_PRINT_COUNTER=0
fi
printf "%19s %3d°C %3d°C %3s°C %5s°C %40s %51s %s\n" "$(date +"%d-%m-%Y %T")" $INLET_TEMPERATURE $CPU1_TEMPERATURE "$CPU2_TEMPERATURE" "$EXHAUST_TEMPERATURE" "$CURRENT_FAN_CONTROL_PROFILE" "$THIRD_PARTY_PCIE_CARD_DELL_DEFAULT_COOLING_RESPONSE_STATUS" "$COMMENT"
print_temperature_array_line "$INLET_TEMPERATURE" "$CPUS_TEMPERATURES" "$EXHAUST_TEMPERATURE" "$CURRENT_FAN_CONTROL_PROFILE" "$THIRD_PARTY_PCIE_CARD_DELL_DEFAULT_COOLING_RESPONSE_STATUS" "$COMMENT"
((TABLE_HEADER_PRINT_COUNTER++))
wait $SLEEP_PROCESS_PID
done

View file

@ -77,6 +77,16 @@ function retrieve_temperatures() {
CPU2_TEMPERATURE="-"
fi
# Initialize CPUS_TEMPERATURES
CPUS_TEMPERATURES="$CPU1_TEMPERATURE"
NUMBER_OF_DETECTED_CPUS=1
# If CPU2 is present, parse its temperature data and add it to CPUS_TEMPERATURES
if [ -n "$CPU2_TEMPERATURE" ]; then
CPUS_TEMPERATURES+=";$CPU2_TEMPERATURE"
((NUMBER_OF_DETECTED_CPUS++))
fi
# Parse inlet temperature data
INLET_TEMPERATURE=$(echo "$DATA" | grep Inlet | grep -Po '\d{2}' | tail -1)
@ -147,6 +157,69 @@ function get_Dell_server_model() {
fi
}
function build_header() {
# Check number of arguments
if [ "$#" -ne 1 ]; then
print_error "build_header() requires an argument (number_of_CPUs)"
return 1
fi
local -r number_of_CPUs="$1"
local -r CPU_column_width=7
local -r Exhaust_column_width=9
local header=" ----" # Width ready for 1 CPU
# Calculate the number of dashes to add on each side of the title
number_of_dashes=$(((number_of_CPUs-1)*CPU_column_width/2))
# Loop to add dashes
for ((i=1; i<=number_of_dashes; i++)); do
header+="-"
done
header+=" Temperatures ---"
# Check parity and add an extra dash on the right if odd
if (( (number_of_CPUs - 1) * CPU_column_width % 2 != 0 )); then
header+="-"
fi
# Loop to add dashes
for ((i=1; i<=number_of_dashes; i++)); do
header+="-"
done
header+=$'\n Date & time Inlet CPU 1 '
# Loop to add CPU columns
for ((i=2; i<=number_of_CPUs; i++)); do
header+=" CPU $i "
done
header+=$' Exhaust Active fan speed profile Third-party PCIe card Dell default cooling response Comment'
printf "%s" "$header"
}
function print_temperature_array_line() {
local -r LOCAL_INLET_TEMPERATURE="$1"
local -r LOCAL_CPUS_TEMPERATURES="$2"
local -r LOCAL_EXHAUST_TEMPERATURE="$3"
local -r LOCAL_CURRENT_FAN_CONTROL_PROFILE="$4"
local -r LOCAL_THIRD_PARTY_PCIE_CARD_DELL_DEFAULT_COOLING_RESPONSE_STATUS="$5"
local -r LOCAL_COMMENT="$6"
# Creating an array from the string
local -r CPUs_temperatures_array=(${LOCAL_CPUS_TEMPERATURES//;/ })
printf "%19s %3d°C " "$(date +"%d-%m-%Y %T")" $LOCAL_INLET_TEMPERATURE
# Itération sur les températures dans le tableau
for temperature in "${CPUs_temperatures_array[@]}"; do
printf " %3d°C " $temperature
done
printf " %5s°C %40s %51s %s\n" "$LOCAL_EXHAUST_TEMPERATURE" "$LOCAL_CURRENT_FAN_CONTROL_PROFILE" "$LOCAL_THIRD_PARTY_PCIE_CARD_DELL_DEFAULT_COOLING_RESPONSE_STATUS" "$LOCAL_COMMENT"
}
# Define functions to check if CPU 1 and CPU 2 temperatures are above the threshold
function CPU1_OVERHEATING() { [ $CPU1_TEMPERATURE -gt "$CPU_TEMPERATURE_THRESHOLD" ]; }
function CPU2_OVERHEATING() { [ $CPU2_TEMPERATURE -gt "$CPU_TEMPERATURE_THRESHOLD" ]; }