Nettoyage du code et refonte complète du README

- Suppression du code mort et commenté (fonctions inutiles)
- Correction du bug wait $SLEEP -> wait $SLEEP_PROCESS_PID
- Suppression des fichiers de sauvegarde .default
- Refonte complète du README en français avec :
  * Documentation des nouveaux paramètres de contrôle dynamique
  * Exemples Docker/docker-compose mis à jour
  * Section dépannage adaptée au système de seuils
  * Logique de fonctionnement détaillée

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-08-31 10:43:45 +02:00
parent 5c73f2d2c5
commit 3a96167120
5 changed files with 106 additions and 343 deletions

View File

@@ -74,13 +74,6 @@ then
echo "" echo ""
fi fi
# Fonction pour régler la vitesse des ventilateurs
#set_fan_speed() {
# local speed=$1
# # Commande pour définir la vitesse des ventilateurs via l'iDRAC
# # Par exemple: ipmitool raw command
# ipmitool -I lanplus -H ${IDRAC_HOST} -U ${IDRAC_USERNAME} -P ${IDRAC_PASSWORD} raw 0x30 0x30 0x02 0xff ${speed}
#}
# Start monitoring # Start monitoring
while true; do while true; do
@@ -141,7 +134,6 @@ while true; do
set_fan_speed ${FAN_SPEEDS[-1]} set_fan_speed ${FAN_SPEEDS[-1]}
fi fi
# apply_user_fan_control_profile
# Check if user fan control profile is applied then apply it if not # Check if user fan control profile is applied then apply it if not
if $IS_DELL_FAN_CONTROL_PROFILE_APPLIED if $IS_DELL_FAN_CONTROL_PROFILE_APPLIED
@@ -171,5 +163,5 @@ while true; do
fi 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" 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"
((i++)) ((i++))
wait $SLEEP wait $SLEEP_PROCESS_PID
done done

View File

@@ -1,162 +0,0 @@
#!/bin/bash
# Enable strict bash mode to stop the script if an uninitialized variable is used, if a command fails, or if a command with a pipe fails
# Not working in some setups : https://github.com/tigerblue77/Dell_iDRAC_fan_controller/issues/48
# set -euo pipefail
source functions.sh
# Trap the signals for container exit and run gracefull_exit function
trap 'gracefull_exit' SIGQUIT SIGKILL SIGTERM
# Prepare, format and define initial variables
# readonly DELL_FRESH_AIR_COMPLIANCE=45
# Check if FAN_SPEED variable is in hexadecimal format. If not, convert it to hexadecimal
if [[ $FAN_SPEED == 0x* ]]
then
readonly DECIMAL_FAN_SPEED=$(printf '%d' $FAN_SPEED)
readonly HEXADECIMAL_FAN_SPEED=$FAN_SPEED
else
readonly DECIMAL_FAN_SPEED=$FAN_SPEED
readonly HEXADECIMAL_FAN_SPEED=$(convert_decimal_value_to_hexadecimal $FAN_SPEED)
fi
# Check if the iDRAC host is set to 'local' or not then set the IDRAC_LOGIN_STRING accordingly
if [[ $IDRAC_HOST == "local" ]]
then
# Check that the Docker host IPMI device (the iDRAC) has been exposed to the Docker container
if [ ! -e "/dev/ipmi0" ] && [ ! -e "/dev/ipmi/0" ] && [ ! -e "/dev/ipmidev/0" ]; then
echo "/!\ Could not open device at /dev/ipmi0 or /dev/ipmi/0 or /dev/ipmidev/0, check that you added the device to your Docker container or stop using local mode. Exiting." >&2
exit 1
fi
IDRAC_LOGIN_STRING='open'
else
echo "iDRAC/IPMI username: $IDRAC_USERNAME"
echo "iDRAC/IPMI password: $IDRAC_PASSWORD"
IDRAC_LOGIN_STRING="lanplus -H $IDRAC_HOST -U $IDRAC_USERNAME -P $IDRAC_PASSWORD"
fi
get_Dell_server_model
if [[ ! $SERVER_MANUFACTURER == "DELL" ]]
then
echo "/!\ Your server isn't a Dell product. Exiting." >&2
exit 1
fi
# Log main informations
echo "Server model: $SERVER_MANUFACTURER $SERVER_MODEL"
echo "iDRAC/IPMI host: $IDRAC_HOST"
# Log the fan speed objective, CPU temperature threshold and check interval
echo "Fan speed objective: $DECIMAL_FAN_SPEED%"
echo "CPU temperature threshold: $CPU_TEMPERATURE_THRESHOLD°C"
echo "Check interval: ${CHECK_INTERVAL}s"
echo ""
# Define the interval for printing
readonly TABLE_HEADER_PRINT_INTERVAL=10
i=$TABLE_HEADER_PRINT_INTERVAL
# Set the flag used to check if the active fan control profile has changed
IS_DELL_FAN_CONTROL_PROFILE_APPLIED=true
# Check present sensors
IS_EXHAUST_TEMPERATURE_SENSOR_PRESENT=true
IS_CPU2_TEMPERATURE_SENSOR_PRESENT=true
retrieve_temperatures $IS_EXHAUST_TEMPERATURE_SENSOR_PRESENT $IS_CPU2_TEMPERATURE_SENSOR_PRESENT
if [ -z "$EXHAUST_TEMPERATURE" ]
then
echo "No exhaust temperature sensor detected."
IS_EXHAUST_TEMPERATURE_SENSOR_PRESENT=false
fi
if [ -z "$CPU2_TEMPERATURE" ]
then
echo "No CPU2 temperature sensor detected."
IS_CPU2_TEMPERATURE_SENSOR_PRESENT=false
fi
# Output new line to beautify output if one of the previous conditions have echoed
if ! $IS_EXHAUST_TEMPERATURE_SENSOR_PRESENT || ! $IS_CPU2_TEMPERATURE_SENSOR_PRESENT
then
echo ""
fi
# Start monitoring
while true; do
# Sleep for the specified interval before taking another reading
sleep $CHECK_INTERVAL &
SLEEP_PROCESS_PID=$!
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
if CPU1_OVERHEAT
then
apply_Dell_fan_control_profile
if ! $IS_DELL_FAN_CONTROL_PROFILE_APPLIED
then
IS_DELL_FAN_CONTROL_PROFILE_APPLIED=true
# If CPU 2 temperature sensor is present, check if it is overheating too.
# Do not apply Dell default dynamic fan control profile as it has already been applied before
if $IS_CPU2_TEMPERATURE_SENSOR_PRESENT && CPU2_OVERHEAT
then
COMMENT="CPU 1 and CPU 2 temperatures are too high, Dell default dynamic fan control profile applied for safety"
else
COMMENT="CPU 1 temperature is too high, Dell default dynamic fan control profile applied for safety"
fi
fi
# If CPU 2 temperature sensor is present, check if it is overheating then apply Dell default dynamic fan control profile if true
elif $IS_CPU2_TEMPERATURE_SENSOR_PRESENT && CPU2_OVERHEAT
then
apply_Dell_fan_control_profile
if ! $IS_DELL_FAN_CONTROL_PROFILE_APPLIED
then
IS_DELL_FAN_CONTROL_PROFILE_APPLIED=true
COMMENT="CPU 2 temperature is too high, Dell default dynamic fan control profile applied for safety"
fi
else
apply_user_fan_control_profile
# Check if user fan control profile is applied then apply it if not
if $IS_DELL_FAN_CONTROL_PROFILE_APPLIED
then
IS_DELL_FAN_CONTROL_PROFILE_APPLIED=false
COMMENT="CPU temperature decreased and is now OK (<= $CPU_TEMPERATURE_THRESHOLD°C), user's fan control profile applied."
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
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
# Print temperatures, active fan control profile and comment if any change happened during last time interval
if [ $i -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"
i=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"
((i++))
wait $SLEEP_PROCESS_PID
done

147
README.md
View File

@@ -1,10 +1,14 @@
<div id="top"></div> <div id="top"></div>
# Dell iDRAC fan controller Docker image # Contrôleur de ventilateurs Dell iDRAC - Version modifiée
Fork de : https://github.com/tigerblue77/Dell_iDRAC_fan_controller_Docker.git<br>
Download Docker image from : Fork de : https://github.com/tigerblue77/Dell_iDRAC_fan_controller_Docker.git
- [Docker Hub](https://hub.docker.com/repository/docker/itrass/idrac_fan_control)
**Modifications apportées :**
- Remplacement du contrôle statique par un contrôle dynamique basé sur la température
- Configuration de 4 seuils de température avec vitesses correspondantes
- Gestion progressive de la vitesse des ventilateurs selon la température du CPU
<!-- TABLE OF CONTENTS --> <!-- TABLE OF CONTENTS -->
<details> <details>
@@ -52,12 +56,19 @@ docker run -d \
--name Dell_iDRAC_fan_controller \ --name Dell_iDRAC_fan_controller \
--restart=unless-stopped \ --restart=unless-stopped \
-e IDRAC_HOST=local \ -e IDRAC_HOST=local \
-e FAN_SPEED=<decimal or hexadecimal fan speed> \ -e CPU_TEMPERATURE_THRESHOLD=<seuil de sécurité en °C> \
-e CPU_TEMPERATURE_THRESHOLD=<decimal temperature threshold> \ -e CHECK_INTERVAL=<secondes entre chaque vérification> \
-e CHECK_INTERVAL=<seconds between each check> \ -e CPU_TEMPERATURE_1=30 \
-e CPU_TEMPERATURE_2=40 \
-e CPU_TEMPERATURE_3=50 \
-e CPU_TEMPERATURE_4=60 \
-e FAN_SPEED_1=10 \
-e FAN_SPEED_2=30 \
-e FAN_SPEED_3=60 \
-e FAN_SPEED_4=80 \
-e DISABLE_THIRD_PARTY_PCIE_CARD_DELL_DEFAULT_COOLING_RESPONSE=<true or false> \ -e DISABLE_THIRD_PARTY_PCIE_CARD_DELL_DEFAULT_COOLING_RESPONSE=<true or false> \
--device=/dev/ipmi0:/dev/ipmi0:rw \ --device=/dev/ipmi0:/dev/ipmi0:rw \
tigerblue77/dell_idrac_fan_controller:latest votre_image:latest
``` ```
2. with LAN iDRAC: 2. with LAN iDRAC:
@@ -66,14 +77,21 @@ docker run -d \
docker run -d \ docker run -d \
--name Dell_iDRAC_fan_controller \ --name Dell_iDRAC_fan_controller \
--restart=unless-stopped \ --restart=unless-stopped \
-e IDRAC_HOST=<iDRAC IP address> \ -e IDRAC_HOST=<adresse IP iDRAC> \
-e IDRAC_USERNAME=<iDRAC username> \ -e IDRAC_USERNAME=<nom d'utilisateur iDRAC> \
-e IDRAC_PASSWORD=<iDRAC password> \ -e IDRAC_PASSWORD=<mot de passe iDRAC> \
-e FAN_SPEED=<decimal or hexadecimal fan speed> \ -e CPU_TEMPERATURE_THRESHOLD=<seuil de sécurité en °C> \
-e CPU_TEMPERATURE_THRESHOLD=<decimal temperature threshold> \ -e CHECK_INTERVAL=<secondes entre chaque vérification> \
-e CHECK_INTERVAL=<seconds between each check> \ -e CPU_TEMPERATURE_1=30 \
-e CPU_TEMPERATURE_2=40 \
-e CPU_TEMPERATURE_3=50 \
-e CPU_TEMPERATURE_4=60 \
-e FAN_SPEED_1=10 \
-e FAN_SPEED_2=30 \
-e FAN_SPEED_3=60 \
-e FAN_SPEED_4=80 \
-e DISABLE_THIRD_PARTY_PCIE_CARD_DELL_DEFAULT_COOLING_RESPONSE=<true or false> \ -e DISABLE_THIRD_PARTY_PCIE_CARD_DELL_DEFAULT_COOLING_RESPONSE=<true or false> \
tigerblue77/dell_idrac_fan_controller:latest votre_image:latest
``` ```
`docker-compose.yml` examples: `docker-compose.yml` examples:
@@ -85,15 +103,22 @@ version: '3.8'
services: services:
Dell_iDRAC_fan_controller: Dell_iDRAC_fan_controller:
image: tigerblue77/dell_idrac_fan_controller:latest image: votre_image:latest
container_name: Dell_iDRAC_fan_controller container_name: Dell_iDRAC_fan_controller
restart: unless-stopped restart: unless-stopped
environment: environment:
- IDRAC_HOST=local - IDRAC_HOST=local
- FAN_SPEED=<decimal or hexadecimal fan speed> - CPU_TEMPERATURE_THRESHOLD=70
- CPU_TEMPERATURE_THRESHOLD=<decimal temperature threshold> - CHECK_INTERVAL=60
- CHECK_INTERVAL=<seconds between each check> - CPU_TEMPERATURE_1=30
- DISABLE_THIRD_PARTY_PCIE_CARD_DELL_DEFAULT_COOLING_RESPONSE=<true or false> - CPU_TEMPERATURE_2=40
- CPU_TEMPERATURE_3=50
- CPU_TEMPERATURE_4=60
- FAN_SPEED_1=10
- FAN_SPEED_2=30
- FAN_SPEED_3=60
- FAN_SPEED_4=80
- DISABLE_THIRD_PARTY_PCIE_CARD_DELL_DEFAULT_COOLING_RESPONSE=false
devices: devices:
- /dev/ipmi0:/dev/ipmi0:rw - /dev/ipmi0:/dev/ipmi0:rw
``` ```
@@ -105,42 +130,80 @@ version: '3.8'
services: services:
Dell_iDRAC_fan_controller: Dell_iDRAC_fan_controller:
image: tigerblue77/dell_idrac_fan_controller:latest image: votre_image:latest
container_name: Dell_iDRAC_fan_controller container_name: Dell_iDRAC_fan_controller
restart: unless-stopped restart: unless-stopped
environment: environment:
- IDRAC_HOST=<iDRAC IP address> - IDRAC_HOST=192.168.1.100
- IDRAC_USERNAME=<iDRAC username> - IDRAC_USERNAME=root
- IDRAC_PASSWORD=<iDRAC password> - IDRAC_PASSWORD=calvin
- FAN_SPEED=<decimal or hexadecimal fan speed> - CPU_TEMPERATURE_THRESHOLD=70
- CPU_TEMPERATURE_THRESHOLD=<decimal temperature threshold> - CHECK_INTERVAL=60
- CHECK_INTERVAL=<seconds between each check> - CPU_TEMPERATURE_1=30
- DISABLE_THIRD_PARTY_PCIE_CARD_DELL_DEFAULT_COOLING_RESPONSE=<true or false> - CPU_TEMPERATURE_2=40
- CPU_TEMPERATURE_3=50
- CPU_TEMPERATURE_4=60
- FAN_SPEED_1=10
- FAN_SPEED_2=30
- FAN_SPEED_3=60
- FAN_SPEED_4=80
- DISABLE_THIRD_PARTY_PCIE_CARD_DELL_DEFAULT_COOLING_RESPONSE=false
``` ```
<p align="right">(<a href="#top">back to top</a>)</p> <p align="right">(<a href="#top">back to top</a>)</p>
<!-- PARAMETERS --> <!-- PARAMETERS -->
## Parameters ## Paramètres
All parameters are optional as they have default values (including default iDRAC username and password). Tous les paramètres sont optionnels car ils ont des valeurs par défaut.
- `IDRAC_HOST` parameter can be set to "local" or to your distant iDRAC's IP address. **Default** value is "local". **Connexion iDRAC :**
- `IDRAC_USERNAME` parameter is only necessary if you're adressing a distant iDRAC. **Default** value is "root". - `IDRAC_HOST` : peut être défini sur "local" ou l'adresse IP de votre iDRAC distant. **Défaut** : "local"
- `IDRAC_PASSWORD` parameter is only necessary if you're adressing a distant iDRAC. **Default** value is "calvin". - `IDRAC_USERNAME` : nécessaire uniquement pour un iDRAC distant. **Défaut** : "root"
- `FAN_SPEED` parameter can be set as a decimal (from 0 to 100%) or hexadecimaladecimal value (from 0x00 to 0x64) you want to set the fans to. **Default** value is 5(%). - `IDRAC_PASSWORD` : nécessaire uniquement pour un iDRAC distant. **Défaut** : "calvin"
- `CPU_TEMPERATURE_THRESHOLD` parameter is the T°junction (junction temperature) threshold beyond which the Dell fan mode defined in your BIOS will become active again (to protect the server hardware against overheat). **Default** value is 50(°C).
- `CHECK_INTERVAL` parameter is the time (in seconds) between each temperature check and potential profile change. **Default** value is 60(s). **Contrôle dynamique des ventilateurs :**
- `DISABLE_THIRD_PARTY_PCIE_CARD_DELL_DEFAULT_COOLING_RESPONSE` parameter is a boolean that allows to disable third-party PCIe card Dell default cooling response. **Default** value is false. - `CPU_TEMPERATURE_1` à `CPU_TEMPERATURE_4` : seuils de température en °C. **Défauts** : 30, 40, 50, 60
- `FAN_SPEED_1` à `FAN_SPEED_4` : vitesses des ventilateurs (0-100%) correspondant aux seuils. **Défauts** : 10, 30, 60, 80
- `CPU_TEMPERATURE_THRESHOLD` : seuil de sécurité au-delà duquel le mode Dell par défaut est activé. **Défaut** : 70°C
**Autres paramètres :**
- `CHECK_INTERVAL` : temps en secondes entre chaque vérification. **Défaut** : 60s
- `DISABLE_THIRD_PARTY_PCIE_CARD_DELL_DEFAULT_COOLING_RESPONSE` : désactive la réponse de refroidissement Dell pour les cartes PCIe tierces. **Défaut** : false
**Logique de fonctionnement :**
- Si la température CPU ≤ `CPU_TEMPERATURE_1` → vitesse `FAN_SPEED_1`
- Si `CPU_TEMPERATURE_1` < température ≤ `CPU_TEMPERATURE_2` → vitesse `FAN_SPEED_2`
- Si `CPU_TEMPERATURE_2` < température ≤ `CPU_TEMPERATURE_3` → vitesse `FAN_SPEED_3`
- Si `CPU_TEMPERATURE_3` < température ≤ `CPU_TEMPERATURE_4` → vitesse `FAN_SPEED_4`
- Si température > `CPU_TEMPERATURE_4` → 100%
- Si température > `CPU_TEMPERATURE_THRESHOLD` → mode Dell par défaut (sécurité)
<p align="right">(<a href="#top">back to top</a>)</p> <p align="right">(<a href="#top">back to top</a>)</p>
<!-- TROUBLESHOOTING --> <!-- TROUBLESHOOTING -->
## Troubleshooting ## Dépannage
If your server frequently switches back to the default Dell fan mode: Si votre serveur revient fréquemment au mode Dell par défaut :
1. Check `Tcase` (case temperature) of your CPU on Intel Ark website and then set `CPU_TEMPERATURE_THRESHOLD` to a slightly lower value. Example with my CPUs ([Intel Xeon E5-2630L v2](https://www.intel.com/content/www/us/en/products/sku/75791/intel-xeon-processor-e52630l-v2-15m-cache-2-40-ghz/specifications.html)) : Tcase = 63°C, I set `CPU_TEMPERATURE_THRESHOLD` to 60(°C).
2. If it's already good, adapt your `FAN_SPEED` value to increase the airflow and thus further decrease the temperature of your CPU(s) 1. **Vérifiez la Tcase de votre CPU** : Consultez le site Intel Ark pour connaître la température de boîtier maximum de votre CPU et définissez `CPU_TEMPERATURE_THRESHOLD` à une valeur légèrement inférieure. Exemple : pour un Intel Xeon E5-2630L v2 avec Tcase = 63°C, définir `CPU_TEMPERATURE_THRESHOLD=60`.
3. If neither increasing the fan speed nor increasing the threshold solves your problem, then it may be time to replace your thermal paste
2. **Ajustez les seuils de température** : Modifiez `CPU_TEMPERATURE_1` à `CPU_TEMPERATURE_4` selon votre environnement. Exemple pour un environnement plus chaud :
```
CPU_TEMPERATURE_1=35
CPU_TEMPERATURE_2=45
CPU_TEMPERATURE_3=55
CPU_TEMPERATURE_4=65
```
3. **Augmentez les vitesses de ventilation** : Adaptez `FAN_SPEED_1` à `FAN_SPEED_4` pour améliorer le refroidissement :
```
FAN_SPEED_1=15
FAN_SPEED_2=35
FAN_SPEED_3=70
FAN_SPEED_4=90
```
4. **Si les problèmes persistent** : Il peut être nécessaire de remplacer la pâte thermique de votre serveur.
<p align="right">(<a href="#top">back to top</a>)</p> <p align="right">(<a href="#top">back to top</a>)</p>

View File

@@ -1,5 +1,3 @@
# Define global functions
# This function applies Dell's default dynamic fan control profile # This function applies Dell's default dynamic fan control profile
function apply_Dell_fan_control_profile () { function apply_Dell_fan_control_profile () {
# Use ipmitool to send the raw command to set fan control to Dell default # Use ipmitool to send the raw command to set fan control to Dell default
@@ -79,22 +77,6 @@ function disable_third_party_PCIe_card_Dell_default_cooling_response () {
ipmitool -I $IDRAC_LOGIN_STRING raw 0x30 0xce 0x00 0x16 0x05 0x00 0x00 0x00 0x05 0x00 0x01 0x00 0x00 > /dev/null ipmitool -I $IDRAC_LOGIN_STRING raw 0x30 0xce 0x00 0x16 0x05 0x00 0x00 0x00 0x05 0x00 0x01 0x00 0x00 > /dev/null
} }
# Returns :
# - 0 if third-party PCIe card Dell default cooling response is currently DISABLED
# - 1 if third-party PCIe card Dell default cooling response is currently ENABLED
# - 2 if the current status returned by ipmitool command output is unexpected
# function is_third_party_PCIe_card_Dell_default_cooling_response_disabled() {
# THIRD_PARTY_PCIE_CARD_COOLING_RESPONSE=$(ipmitool -I $IDRAC_LOGIN_STRING raw 0x30 0xce 0x01 0x16 0x05 0x00 0x00 0x00)
# if [ "$THIRD_PARTY_PCIE_CARD_COOLING_RESPONSE" == "16 05 00 00 00 05 00 01 00 00" ]; then
# return 0
# elif [ "$THIRD_PARTY_PCIE_CARD_COOLING_RESPONSE" == "16 05 00 00 00 05 00 00 00 00" ]; then
# return 1
# else
# echo "Unexpected output: $THIRD_PARTY_PCIE_CARD_COOLING_RESPONSE" >&2
# return 2
# fi
# }
# Prepare traps in case of container exit # Prepare traps in case of container exit
function gracefull_exit () { function gracefull_exit () {

View File

@@ -1,112 +0,0 @@
# Define global functions
# This function applies Dell's default dynamic fan control profile
function apply_Dell_fan_control_profile () {
# Use ipmitool to send the raw command to set fan control to Dell default
ipmitool -I $IDRAC_LOGIN_STRING raw 0x30 0x30 0x01 0x01 > /dev/null
CURRENT_FAN_CONTROL_PROFILE="Dell default dynamic fan control profile"
}
# This function applies a user-specified static fan control profile
function apply_user_fan_control_profile () {
# Use ipmitool to send the raw command to set fan control to user-specified value
ipmitool -I $IDRAC_LOGIN_STRING raw 0x30 0x30 0x01 0x00 > /dev/null
ipmitool -I $IDRAC_LOGIN_STRING raw 0x30 0x30 0x02 0xff $HEXADECIMAL_FAN_SPEED > /dev/null
CURRENT_FAN_CONTROL_PROFILE="User static fan control profile ($DECIMAL_FAN_SPEED%)"
}
# Convert first parameter given ($DECIMAL_NUMBER) to hexadecimal
# Usage : convert_decimal_value_to_hexadecimal $DECIMAL_NUMBER
# Returns : hexadecimal value of DECIMAL_NUMBER
function convert_decimal_value_to_hexadecimal () {
local DECIMAL_NUMBER=$1
local HEXADECIMAL_NUMBER=$(printf '0x%02x' $DECIMAL_NUMBER)
echo $HEXADECIMAL_NUMBER
}
# Retrieve temperature sensors data using ipmitool
# Usage : retrieve_temperatures $IS_EXHAUST_TEMPERATURE_SENSOR_PRESENT $IS_CPU2_TEMPERATURE_SENSOR_PRESENT
function retrieve_temperatures () {
if (( $# != 2 ))
then
printf "Illegal number of parameters.\nUsage: retrieve_temperatures \$IS_EXHAUST_TEMPERATURE_SENSOR_PRESENT \$IS_CPU2_TEMPERATURE_SENSOR_PRESENT" >&2
return 1
fi
local IS_EXHAUST_TEMPERATURE_SENSOR_PRESENT=$1
local IS_CPU2_TEMPERATURE_SENSOR_PRESENT=$2
local DATA=$(ipmitool -I $IDRAC_LOGIN_STRING sdr type temperature | grep degrees)
# Parse CPU data
local CPU_DATA=$(echo "$DATA" | grep "3\." | grep -Po '\d{2}')
CPU1_TEMPERATURE=$(echo $CPU_DATA | awk '{print $1;}')
if $IS_CPU2_TEMPERATURE_SENSOR_PRESENT
then
CPU2_TEMPERATURE=$(echo $CPU_DATA | awk '{print $2;}')
else
CPU2_TEMPERATURE="-"
fi
# Parse inlet temperature data
INLET_TEMPERATURE=$(echo "$DATA" | grep Inlet | grep -Po '\d{2}' | tail -1)
# If exhaust temperature sensor is present, parse its temperature data
if $IS_EXHAUST_TEMPERATURE_SENSOR_PRESENT
then
EXHAUST_TEMPERATURE=$(echo "$DATA" | grep Exhaust | grep -Po '\d{2}' | tail -1)
else
EXHAUST_TEMPERATURE="-"
fi
}
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
ipmitool -I $IDRAC_LOGIN_STRING raw 0x30 0xce 0x00 0x16 0x05 0x00 0x00 0x00 0x05 0x00 0x00 0x00 0x00 > /dev/null
}
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
ipmitool -I $IDRAC_LOGIN_STRING raw 0x30 0xce 0x00 0x16 0x05 0x00 0x00 0x00 0x05 0x00 0x01 0x00 0x00 > /dev/null
}
# Returns :
# - 0 if third-party PCIe card Dell default cooling response is currently DISABLED
# - 1 if third-party PCIe card Dell default cooling response is currently ENABLED
# - 2 if the current status returned by ipmitool command output is unexpected
# function is_third_party_PCIe_card_Dell_default_cooling_response_disabled() {
# THIRD_PARTY_PCIE_CARD_COOLING_RESPONSE=$(ipmitool -I $IDRAC_LOGIN_STRING raw 0x30 0xce 0x01 0x16 0x05 0x00 0x00 0x00)
# if [ "$THIRD_PARTY_PCIE_CARD_COOLING_RESPONSE" == "16 05 00 00 00 05 00 01 00 00" ]; then
# return 0
# elif [ "$THIRD_PARTY_PCIE_CARD_COOLING_RESPONSE" == "16 05 00 00 00 05 00 00 00 00" ]; then
# return 1
# else
# echo "Unexpected output: $THIRD_PARTY_PCIE_CARD_COOLING_RESPONSE" >&2
# return 2
# fi
# }
# Prepare traps in case of container exit
function gracefull_exit () {
apply_Dell_fan_control_profile
enable_third_party_PCIe_card_Dell_default_cooling_response
echo "/!\ WARNING /!\ Container stopped, Dell default dynamic fan control profile applied for safety."
exit 0
}
# Helps debugging when people are posting their output
function get_Dell_server_model () {
IPMI_FRU_content=$(ipmitool -I $IDRAC_LOGIN_STRING fru 2>/dev/null) # FRU stands for "Field Replaceable Unit"
SERVER_MANUFACTURER=$(echo "$IPMI_FRU_content" | grep "Product Manufacturer" | awk -F ': ' '{print $2}')
SERVER_MODEL=$(echo "$IPMI_FRU_content" | grep "Product Name" | awk -F ': ' '{print $2}')
# Check if SERVER_MANUFACTURER is empty, if yes, assign value based on "Board Mfg"
if [ -z "$SERVER_MANUFACTURER" ]; then
SERVER_MANUFACTURER=$(echo "$IPMI_FRU_content" | tr -s ' ' | grep "Board Mfg :" | awk -F ': ' '{print $2}')
fi
# Check if SERVER_MODEL is empty, if yes, assign value based on "Board Product"
if [ -z "$SERVER_MODEL" ]; then
SERVER_MODEL=$(echo "$IPMI_FRU_content" | tr -s ' ' | grep "Board Product :" | awk -F ': ' '{print $2}')
fi
}