Ajout version LXC et restructuration complète du projet

🚀 NOUVELLES FONCTIONNALITÉS :
- Version LXC complète pour Proxmox avec installation automatisée
- Script d'installation LXC avec interface colorée et vérifications
- Service systemd avec configuration sécurisée
- Script de désinstallation avec sauvegarde de config

📁 RESTRUCTURATION :
- Séparation Docker/LXC dans des dossiers dédiés
- Documentation spécialisée pour chaque version
- Guide d'installation unifié (INSTALL.md)
- README principal avec comparaison des versions

🐳 AMÉLIORATIONS DOCKER :
- docker-compose.yml optimisé avec healthcheck
- Documentation Docker détaillée
- Configuration par variables d'environnement clarifiée

📦 FONCTIONNALITÉS LXC :
- Installation en une commande
- Intégration systemd native
- Gestion des permissions et sécurité
- Logs intégrés avec journalctl
- Configuration via fichier d'environnement

🔧 OUTILS INCLUS :
- Scripts d'installation/désinstallation
- Healthchecks pour les deux versions
- Documentation de dépannage
- Comparatif des deux approches

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-08-31 11:00:00 +02:00
parent 3a96167120
commit ced296a296
15 changed files with 1410 additions and 26 deletions

69
INSTALL.md Normal file
View File

@@ -0,0 +1,69 @@
# Guide d'installation
Choisissez votre méthode d'installation préférée :
## 🐳 Version Docker
**Avantages :**
- Installation simple avec Docker Compose
- Environment isolé et reproductible
- Gestion des versions via images Docker
- Intégration facile avec d'autres services
**→ [Guide Docker complet](docker/README-DOCKER.md)**
### Installation rapide Docker
```bash
# Cloner le repo
git clone <votre-repo>
cd Dell_iDRAC_fan_controller/docker
# Configurer
cp docker-compose.yml docker-compose.local.yml
nano docker-compose.local.yml
# Lancer
docker-compose -f docker-compose.local.yml up -d
```
---
## 📦 Version LXC (Proxmox)
**Avantages :**
- Performance native (pas d'overhead Docker)
- Intégration parfaite avec Proxmox
- Accès hardware direct
- Gestion avec systemd
**→ [Guide LXC complet](lxc/README-LXC.md)**
### Installation rapide LXC
```bash
# Dans un container LXC Ubuntu
wget -O - https://github.com/<votre-repo>/archive/main.tar.gz | tar -xz
cd Dell_iDRAC_fan_controller-main/lxc
chmod +x install-lxc.sh
./install-lxc.sh
```
---
## Comparaison rapide
| Critère | Docker | LXC |
|---------|--------|-----|
| **Facilité** | ⭐⭐⭐ | ⭐⭐ |
| **Performance** | ⭐⭐ | ⭐⭐⭐ |
| **Isolation** | ⭐⭐⭐ | ⭐⭐ |
| **Maintenance** | ⭐⭐⭐ | ⭐⭐ |
| **Proxmox** | ⭐⭐ | ⭐⭐⭐ |
| **Ressources** | ⭐⭐ | ⭐⭐⭐ |
## Support
- **Issues** : [GitHub Issues](https://github.com/<votre-repo>/issues)
- **Discussions** : [GitHub Discussions](https://github.com/<votre-repo>/discussions)
- **Original** : [Projet source](https://github.com/tigerblue77/Dell_iDRAC_fan_controller_Docker)

View File

@@ -10,46 +10,81 @@ Fork de : https://github.com/tigerblue77/Dell_iDRAC_fan_controller_Docker.git
- Configuration de 4 seuils de température avec vitesses correspondantes - Configuration de 4 seuils de température avec vitesses correspondantes
- Gestion progressive de la vitesse des ventilateurs selon la température du CPU - Gestion progressive de la vitesse des ventilateurs selon la température du CPU
## 🚀 Deux versions disponibles
| **Version Docker** | **Version LXC Proxmox** |
|-------------------|------------------------|
| 🐳 Container Docker classique | 📦 Container LXC natif |
| Images versionnées | Installation directe |
| `docker-compose` | `systemctl` |
| Isolation forte | Performance native |
| → [Documentation Docker](docker/) | → [Documentation LXC](lxc/) |
<!-- TABLE OF CONTENTS --> <!-- TABLE OF CONTENTS -->
<details> <details>
<summary>Table of Contents</summary> <summary>Table des matières</summary>
<ol> <ol>
<li><a href="#container-console-log-example">Container console log example</a></li> <li><a href="#-deux-versions-disponibles">🚀 Deux versions disponibles</a></li>
<li><a href="#supported-architectures">Supported architectures</a></li> <li><a href="#prérequis">Prérequis</a></li>
<li><a href="#usage">Usage</a></li> <li><a href="#installation-rapide">Installation rapide</a></li>
<li><a href="#parameters">Parameters</a></li> <li><a href="#paramètres">Paramètres</a></li>
<li><a href="#troubleshooting">Troubleshooting</a></li> <li><a href="#dépannage">Dépannage</a></li>
<li><a href="#contributing">Contributing</a></li> <li><a href="#container-console-log-example">Exemple de logs</a></li>
</ol> </ol>
</details> </details>
## Installation rapide
### 🐳 Version Docker
```bash
# Télécharger la configuration
wget https://raw.githubusercontent.com/votre-repo/main/docker/docker-compose.yml
# Modifier la configuration selon vos besoins
nano docker-compose.yml
# Lancer le container
docker-compose up -d
```
### 📦 Version LXC (Proxmox)
```bash
# Dans le container LXC Ubuntu
wget -O - https://github.com/votre-repo/archive/main.tar.gz | tar -xz
cd Dell_iDRAC_fan_controller-main/lxc
chmod +x install-lxc.sh
./install-lxc.sh
```
<p align="right">(<a href="#top">back to top</a>)</p>
## Prérequis
### Serveur Dell
- Dell PowerEdge avec iDRAC
- Support des commandes IPMI
- iDRAC 9 firmware < 3.30.30.30 (pour IPMI)
### Environnement
- **Docker** : Docker + Docker Compose
- **LXC** : Proxmox avec container privilégié
<p align="right">(<a href="#top">back to top</a>)</p>
## Container console log example ## Container console log example
![image](https://user-images.githubusercontent.com/37409593/216442212-d2ad7ff7-0d6f-443f-b8ac-c67b5f613b83.png) ![image](https://user-images.githubusercontent.com/37409593/216442212-d2ad7ff7-0d6f-443f-b8ac-c67b5f613b83.png)
<p align="right">(<a href="#top">back to top</a>)</p> <p align="right">(<a href="#top">back to top</a>)</p>
<!-- PREREQUISITES --> <!-- USAGE DÉTAILLÉ -->
## Prerequisites ## Configuration détaillée
### iDRAC version
This Docker container only works on Dell PowerEdge servers that support IPMI commands, i.e. < iDRAC 9 firmware 3.30.30.30. ### 🐳 Version Docker
<p align="right">(<a href="#top">back to top</a>)</p> **1. Utilisation avec iDRAC local :**
<!-- SUPPORTED ARCHITECTURES -->
## Supported architectures
This Docker container is currently built and available for the following CPU architectures :
- AMD64
- ARM64
<p align="right">(<a href="#top">back to top</a>)</p>
<!-- USAGE -->
## Usage
1. with local iDRAC:
```bash ```bash
docker run -d \ docker run -d \

View File

@@ -0,0 +1,167 @@
#!/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
# Define the temperature thresholds and corresponding fan speeds
TEMP_THRESHOLDS=($CPU_TEMPERATURE_1 $CPU_TEMPERATURE_2 $CPU_TEMPERATURE_3 $CPU_TEMPERATURE_4)
FAN_SPEEDS=($FAN_SPEED_1 $FAN_SPEED_2 $FAN_SPEED_3 $FAN_SPEED_4 100) # Correspond aux seuils + vitesse max
# 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 check interval
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
# Adjust fan speed based on temperature thresholds
for i in ${!TEMP_THRESHOLDS[@]}; do
if [ $CPU1_TEMPERATURE -le ${TEMP_THRESHOLDS[$i]} ]; then
set_fan_speed ${FAN_SPEEDS[$i]}
break
fi
done
# Si la température est supérieure à tous les seuils, définir la vitesse maximale
if [ $CPU1_TEMPERATURE -gt ${TEMP_THRESHOLDS[-1]} ]; then
set_fan_speed ${FAN_SPEEDS[-1]}
fi
# 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

173
docker/README-DOCKER.md Normal file
View File

@@ -0,0 +1,173 @@
# Version Docker
Documentation spécifique pour l'installation et l'utilisation avec Docker.
## Fichiers inclus
- `Dockerfile` : Image Docker
- `Dell_iDRAC_fan_controller.sh` : Script principal
- `functions.sh` : Fonctions utilitaires
- `healthcheck.sh` : Vérification de santé
## Installation Docker
### 1. Construction de l'image
```bash
cd docker/
docker build -t idrac-fan-controller .
```
### 2. Utilisation avec Docker Compose (recommandé)
**Créer `docker-compose.yml` :**
```yml
version: '3.8'
services:
idrac_fan_controller:
build: .
container_name: idrac_fan_controller
restart: unless-stopped
environment:
# Connexion iDRAC
- IDRAC_HOST=local # ou IP pour distant
- IDRAC_USERNAME=root # si distant
- IDRAC_PASSWORD=calvin # si distant
# Seuils de température (°C)
- CPU_TEMPERATURE_1=30
- CPU_TEMPERATURE_2=40
- CPU_TEMPERATURE_3=50
- CPU_TEMPERATURE_4=60
# Vitesses correspondantes (%)
- FAN_SPEED_1=10
- FAN_SPEED_2=30
- FAN_SPEED_3=60
- FAN_SPEED_4=80
# Seuil de sécurité
- CPU_TEMPERATURE_THRESHOLD=70
# Autres paramètres
- CHECK_INTERVAL=60
- DISABLE_THIRD_PARTY_PCIE_CARD_DELL_DEFAULT_COOLING_RESPONSE=false
devices:
- /dev/ipmi0:/dev/ipmi0:rw # Pour iDRAC local
# Optionnel : logs persistants
volumes:
- ./logs:/var/log/idrac
```
### 3. Lancement
```bash
# Démarrer
docker-compose up -d
# Voir les logs
docker-compose logs -f
# Arrêter
docker-compose down
```
## Configuration par variables d'environnement
Toutes les variables peuvent être configurées via l'environnement :
```bash
# Exemple pour iDRAC distant
docker run -d \
--name idrac_fan_controller \
--restart unless-stopped \
-e IDRAC_HOST=192.168.1.100 \
-e IDRAC_USERNAME=root \
-e IDRAC_PASSWORD=calvin \
-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 CPU_TEMPERATURE_THRESHOLD=70 \
-e CHECK_INTERVAL=60 \
idrac-fan-controller
```
## Gestion
### Commandes utiles
```bash
# État du container
docker-compose ps
# Logs en temps réel
docker-compose logs -f idrac_fan_controller
# Redémarrer
docker-compose restart idrac_fan_controller
# Shell dans le container
docker-compose exec idrac_fan_controller bash
# Test de santé
docker-compose exec idrac_fan_controller ./healthcheck.sh
```
### Mise à jour
```bash
# Reconstruire l'image
docker-compose build
# Redémarrer avec la nouvelle image
docker-compose up -d
```
## Dépannage Docker
### Vérification de l'accès IPMI
```bash
# Dans le container
docker-compose exec idrac_fan_controller ls -la /dev/ipmi*
# Test ipmitool
docker-compose exec idrac_fan_controller ipmitool fru
```
### Erreurs communes
**"Could not open device at /dev/ipmi0"**
```bash
# Vérifier sur l'hôte
ls -la /dev/ipmi*
# Vérifier les permissions
docker-compose exec idrac_fan_controller ls -la /dev/ipmi*
```
**Container qui s'arrête**
```bash
# Voir les logs
docker-compose logs idrac_fan_controller
# Mode debug
docker-compose run --rm idrac_fan_controller bash
```
## Avantages Docker
- **Isolation** : Environment isolé
- **Reproductibilité** : Même environnement partout
- **Versioning** : Images versionnées
- **Rollback** : Retour en arrière facile
- **Orchestration** : Intégration avec autres services

53
docker/docker-compose.yml Normal file
View File

@@ -0,0 +1,53 @@
version: '3.8'
services:
idrac_fan_controller:
build: .
container_name: idrac_fan_controller
restart: unless-stopped
environment:
# Connexion iDRAC
- IDRAC_HOST=local # "local" ou IP pour distant (ex: 192.168.1.100)
- IDRAC_USERNAME=root # Requis seulement si IDRAC_HOST != "local"
- IDRAC_PASSWORD=calvin # Requis seulement si IDRAC_HOST != "local"
# === Seuils de température (°C) ===
# Température <= CPU_TEMPERATURE_1 → vitesse FAN_SPEED_1
- CPU_TEMPERATURE_1=30
# Température <= CPU_TEMPERATURE_2 → vitesse FAN_SPEED_2
- CPU_TEMPERATURE_2=40
# Température <= CPU_TEMPERATURE_3 → vitesse FAN_SPEED_3
- CPU_TEMPERATURE_3=50
# Température <= CPU_TEMPERATURE_4 → vitesse FAN_SPEED_4
- CPU_TEMPERATURE_4=60
# === Vitesses des ventilateurs (%) ===
- FAN_SPEED_1=10 # Vitesse minimale
- FAN_SPEED_2=30
- FAN_SPEED_3=60
- FAN_SPEED_4=80 # Si > CPU_TEMPERATURE_4 → 100%
# === Seuil de sécurité ===
# Si température > CPU_TEMPERATURE_THRESHOLD → mode Dell par défaut
- CPU_TEMPERATURE_THRESHOLD=70
# === Autres paramètres ===
- CHECK_INTERVAL=60 # Secondes entre chaque vérification
- DISABLE_THIRD_PARTY_PCIE_CARD_DELL_DEFAULT_COOLING_RESPONSE=false
# Accès au périphérique IPMI (requis pour IDRAC_HOST=local)
devices:
- /dev/ipmi0:/dev/ipmi0:rw
# Logs persistants (optionnel)
volumes:
- ./logs:/var/log/idrac
# Healthcheck intégré
healthcheck:
test: ["CMD", "/app/healthcheck.sh"]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s

105
docker/functions.sh Executable file
View File

@@ -0,0 +1,105 @@
# 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%)"
}
# This function sets the fan speed to a specified value
# Usage: set_fan_speed <decimal_speed>
function set_fan_speed () {
local SPEED=$1
local HEX_SPEED=$(convert_decimal_value_to_hexadecimal $SPEED)
ipmitool -I $IDRAC_LOGIN_STRING raw 0x30 0x30 0x01 0x00 > /dev/null
ipmitool -I $IDRAC_LOGIN_STRING raw 0x30 0x30 0x02 0xff $HEX_SPEED > /dev/null
CURRENT_FAN_CONTROL_PROFILE="User static fan control profile ($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
}
# 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
}

24
docker/healthcheck.sh Executable file
View File

@@ -0,0 +1,24 @@
#!/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
# 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
ipmitool -I $IDRAC_LOGIN_STRING sdr type temperature

167
lxc/Dell_iDRAC_fan_controller.sh Executable file
View File

@@ -0,0 +1,167 @@
#!/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
# Define the temperature thresholds and corresponding fan speeds
TEMP_THRESHOLDS=($CPU_TEMPERATURE_1 $CPU_TEMPERATURE_2 $CPU_TEMPERATURE_3 $CPU_TEMPERATURE_4)
FAN_SPEEDS=($FAN_SPEED_1 $FAN_SPEED_2 $FAN_SPEED_3 $FAN_SPEED_4 100) # Correspond aux seuils + vitesse max
# 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 check interval
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
# Adjust fan speed based on temperature thresholds
for i in ${!TEMP_THRESHOLDS[@]}; do
if [ $CPU1_TEMPERATURE -le ${TEMP_THRESHOLDS[$i]} ]; then
set_fan_speed ${FAN_SPEEDS[$i]}
break
fi
done
# Si la température est supérieure à tous les seuils, définir la vitesse maximale
if [ $CPU1_TEMPERATURE -gt ${TEMP_THRESHOLDS[-1]} ]; then
set_fan_speed ${FAN_SPEEDS[-1]}
fi
# 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

193
lxc/README-LXC.md Normal file
View File

@@ -0,0 +1,193 @@
# Installation LXC pour Proxmox
Ce guide vous explique comment installer le contrôleur de ventilateurs Dell iDRAC dans un container LXC Proxmox.
## Prérequis
### 1. Container LXC Proxmox
- Template Ubuntu 22.04 LTS
- Container **privilégié** (requis pour l'accès IPMI)
- Accès réseau configuré
### 2. Configuration Proxmox
Dans l'interface Proxmox ou en ligne de commande :
```bash
# Rendre le container privilégié
pct set <VMID> -privilege 1
# Activer nesting si nécessaire
pct set <VMID> -features nesting=1
# Configuration des ressources (exemple)
pct set <VMID> -memory 512 -cores 1
```
### 3. Accès IPMI
**Option A - iDRAC local (dans le container sur l'hôte physique) :**
```bash
# Ajouter l'accès au périphérique IPMI dans la configuration LXC
echo "lxc.cgroup2.devices.allow: c 10:* rwm" >> /etc/pve/lxc/<VMID>.conf
echo "lxc.mount.entry: /dev/ipmi0 dev/ipmi0 none bind,optional,create=file" >> /etc/pve/lxc/<VMID>.conf
```
**Option B - iDRAC distant :**
Aucune configuration matérielle supplémentaire requise.
## Installation
### 1. Téléchargement
```bash
# Dans le container LXC
cd /tmp
wget -O - https://github.com/votre-repo/archive/main.tar.gz | tar -xz
cd Dell_iDRAC_fan_controller-main/lxc
```
### 2. Installation automatique
```bash
chmod +x install-lxc.sh
./install-lxc.sh
```
Le script va :
- Installer ipmitool
- Créer la structure de répertoires
- Copier les fichiers
- Configurer le service systemd
- Créer le fichier de configuration
## Configuration
### 1. Édition de la configuration
```bash
nano /opt/idrac-fan-controller/config/environment
```
### 2. Paramètres principaux
```bash
# Connexion iDRAC
IDRAC_HOST=local # ou IP pour iDRAC distant
IDRAC_USERNAME=root # si iDRAC distant
IDRAC_PASSWORD=calvin # si iDRAC distant
# Seuils de température (°C)
CPU_TEMPERATURE_1=30
CPU_TEMPERATURE_2=40
CPU_TEMPERATURE_3=50
CPU_TEMPERATURE_4=60
# Vitesses correspondantes (%)
FAN_SPEED_1=10
FAN_SPEED_2=30
FAN_SPEED_3=60
FAN_SPEED_4=80
# Seuil de sécurité
CPU_TEMPERATURE_THRESHOLD=70
```
## Utilisation
### Gestion du service
```bash
# Démarrer
systemctl start idrac-fan-controller
# Arrêter
systemctl stop idrac-fan-controller
# Redémarrer
systemctl restart idrac-fan-controller
# Statut
systemctl status idrac-fan-controller
# Activer au démarrage (déjà fait par l'installation)
systemctl enable idrac-fan-controller
```
### Surveillance
```bash
# Logs en temps réel
journalctl -u idrac-fan-controller -f
# Logs récents
journalctl -u idrac-fan-controller -n 50
# Test de santé
/opt/idrac-fan-controller/healthcheck.sh
```
## Dépannage
### Vérification IPMI
```bash
# Test de base
ipmitool fru
# Si erreur "Could not open device"
ls -la /dev/ipmi*
# Doit montrer /dev/ipmi0 ou similaire
# Vérifier les permissions
id
# Doit être root dans le container
```
### Erreurs communes
**"Could not open device at /dev/ipmi0"**
- Vérifier que le container est privilégié
- S'assurer que l'accès IPMI est configuré dans Proxmox
- Redémarrer le container après les changements
**Service qui ne démarre pas**
```bash
# Vérifier la syntaxe du fichier de configuration
systemctl status idrac-fan-controller
# Tester manuellement
cd /opt/idrac-fan-controller
sudo -u root bash Dell_iDRAC_fan_controller.sh
```
## Désinstallation
```bash
cd /tmp/Dell_iDRAC_fan_controller-main/lxc
chmod +x uninstall-lxc.sh
./uninstall-lxc.sh
```
## Comparaison Docker vs LXC
| Aspect | Docker | LXC |
|--------|---------|-----|
| **Installation** | Pull image | Script d'installation |
| **Configuration** | Variables ENV | Fichier de config |
| **Gestion** | docker-compose | systemctl |
| **Logs** | docker logs | journalctl |
| **Ressources** | Container isolé | Container système |
| **Accès hardware** | Device mapping | Accès direct |
| **Maintenance** | Image updates | Package updates |
| **Backup** | Image + volumes | Snapshot LXC |
## Avantages LXC
- **Performance** : Pas d'overhead Docker
- **Intégration** : Gestion native avec Proxmox
- **Accès hardware** : Plus direct et simple
- **Ressources** : Utilisation optimale
- **Logs** : Intégrés avec systemd
- **Maintenance** : Mise à jour avec le système

105
lxc/functions.sh Executable file
View File

@@ -0,0 +1,105 @@
# 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%)"
}
# This function sets the fan speed to a specified value
# Usage: set_fan_speed <decimal_speed>
function set_fan_speed () {
local SPEED=$1
local HEX_SPEED=$(convert_decimal_value_to_hexadecimal $SPEED)
ipmitool -I $IDRAC_LOGIN_STRING raw 0x30 0x30 0x01 0x00 > /dev/null
ipmitool -I $IDRAC_LOGIN_STRING raw 0x30 0x30 0x02 0xff $HEX_SPEED > /dev/null
CURRENT_FAN_CONTROL_PROFILE="User static fan control profile ($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
}
# 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
}

24
lxc/healthcheck.sh Executable file
View File

@@ -0,0 +1,24 @@
#!/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
# 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
ipmitool -I $IDRAC_LOGIN_STRING sdr type temperature

View File

@@ -0,0 +1,39 @@
[Unit]
Description=Dell iDRAC Fan Controller
Documentation=https://github.com/tigerblue77/Dell_iDRAC_fan_controller_Docker
After=network.target
Wants=network.target
[Service]
Type=simple
User=root
Group=root
WorkingDirectory=/opt/idrac-fan-controller
EnvironmentFile=/opt/idrac-fan-controller/config/environment
ExecStart=/opt/idrac-fan-controller/Dell_iDRAC_fan_controller.sh
ExecReload=/bin/kill -HUP $MAINPID
Restart=always
RestartSec=10
KillMode=mixed
TimeoutStopSec=30
# Logging
StandardOutput=journal
StandardError=journal
SyslogIdentifier=idrac-fan-controller
# Security settings
NoNewPrivileges=false
PrivateTmp=true
ProtectHome=true
ProtectSystem=strict
ReadWritePaths=/var/log/idrac-fan-controller
ReadOnlyPaths=/opt/idrac-fan-controller
# Hardware access required for IPMI
DeviceAllow=/dev/ipmi0 rw
DeviceAllow=/dev/ipmi/0 rw
DeviceAllow=/dev/ipmidev/0 rw
[Install]
WantedBy=multi-user.target

125
lxc/install-lxc.sh Executable file
View File

@@ -0,0 +1,125 @@
#!/bin/bash
# Script d'installation du contrôleur de ventilateurs Dell iDRAC pour LXC/Proxmox
# Usage: ./install-lxc.sh
set -euo pipefail
# Couleurs pour l'affichage
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Configuration
INSTALL_DIR="/opt/idrac-fan-controller"
SERVICE_NAME="idrac-fan-controller"
CONFIG_FILE="$INSTALL_DIR/config/environment"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
echo -e "${BLUE}=== Installation du contrôleur de ventilateurs Dell iDRAC ===${NC}"
echo
# Vérifier les privilèges root
if [[ $EUID -ne 0 ]]; then
echo -e "${RED}Erreur: Ce script doit être exécuté en tant que root${NC}"
exit 1
fi
# Vérifier si on est dans un container LXC
if ! systemd-detect-virt --container >/dev/null 2>&1; then
echo -e "${YELLOW}Attention: Ce script est conçu pour un container LXC Proxmox${NC}"
read -p "Continuer quand même ? (y/N): " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 0
fi
fi
echo -e "${BLUE}1. Mise à jour du système...${NC}"
apt-get update -qq
echo -e "${BLUE}2. Installation des dépendances...${NC}"
apt-get install -y ipmitool
echo -e "${BLUE}3. Vérification de l'accès IPMI...${NC}"
if [ ! -e "/dev/ipmi0" ] && [ ! -e "/dev/ipmi/0" ] && [ ! -e "/dev/ipmidev/0" ]; then
echo -e "${YELLOW}Attention: Aucun périphérique IPMI détecté${NC}"
echo -e "${YELLOW}Assurez-vous que le container LXC est configuré avec l'accès au hardware IPMI${NC}"
echo -e "${YELLOW}Configuration Proxmox requise:${NC}"
echo -e "${YELLOW} - Container privilégié (privilege: 1)${NC}"
echo -e "${YELLOW} - Accès au périphérique IPMI configuré${NC}"
echo
fi
echo -e "${BLUE}4. Création de la structure de répertoires...${NC}"
mkdir -p "$INSTALL_DIR/config"
mkdir -p "/var/log/$SERVICE_NAME"
echo -e "${BLUE}5. Copie des fichiers de l'application...${NC}"
cp "$SCRIPT_DIR/../Dell_iDRAC_fan_controller.sh" "$INSTALL_DIR/"
cp "$SCRIPT_DIR/../functions.sh" "$INSTALL_DIR/"
cp "$SCRIPT_DIR/../healthcheck.sh" "$INSTALL_DIR/"
cp "$SCRIPT_DIR/idrac-fan-controller.service" "/etc/systemd/system/"
# Rendre les scripts exécutables
chmod +x "$INSTALL_DIR"/*.sh
echo -e "${BLUE}6. Configuration des variables d'environnement...${NC}"
if [ ! -f "$CONFIG_FILE" ]; then
cat > "$CONFIG_FILE" << 'EOF'
# Configuration du contrôleur de ventilateurs Dell iDRAC
# Modifiez ces valeurs selon votre environnement
# Connexion iDRAC
IDRAC_HOST=local
IDRAC_USERNAME=root
IDRAC_PASSWORD=calvin
# Contrôle dynamique des ventilateurs
CPU_TEMPERATURE_1=30
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
# Seuil de sécurité
CPU_TEMPERATURE_THRESHOLD=70
# Autres paramètres
CHECK_INTERVAL=60
DISABLE_THIRD_PARTY_PCIE_CARD_DELL_DEFAULT_COOLING_RESPONSE=false
EOF
echo -e "${GREEN}Fichier de configuration créé: $CONFIG_FILE${NC}"
else
echo -e "${YELLOW}Fichier de configuration existant conservé: $CONFIG_FILE${NC}"
fi
echo -e "${BLUE}7. Configuration du service systemd...${NC}"
systemctl daemon-reload
systemctl enable "$SERVICE_NAME"
echo -e "${GREEN}=== Installation terminée avec succès ! ===${NC}"
echo
echo -e "${BLUE}Prochaines étapes:${NC}"
echo "1. Éditez la configuration: nano $CONFIG_FILE"
echo "2. Démarrez le service: systemctl start $SERVICE_NAME"
echo "3. Vérifiez le statut: systemctl status $SERVICE_NAME"
echo "4. Consultez les logs: journalctl -u $SERVICE_NAME -f"
echo
echo -e "${BLUE}Commandes utiles:${NC}"
echo "• Démarrer: systemctl start $SERVICE_NAME"
echo "• Arrêter: systemctl stop $SERVICE_NAME"
echo "• Redémarrer: systemctl restart $SERVICE_NAME"
echo "• Statut: systemctl status $SERVICE_NAME"
echo "• Logs: journalctl -u $SERVICE_NAME -f"
echo "• Test: $INSTALL_DIR/healthcheck.sh"
echo
echo -e "${YELLOW}N'oubliez pas de configurer votre container LXC Proxmox avec:${NC}"
echo "• pct set <VMID> -privilege 1"
echo "• pct set <VMID> -features nesting=1"
echo "• Configuration de l'accès IPMI selon votre setup"

105
lxc/uninstall-lxc.sh Executable file
View File

@@ -0,0 +1,105 @@
#!/bin/bash
# Script de désinstallation du contrôleur de ventilateurs Dell iDRAC pour LXC
# Usage: ./uninstall-lxc.sh
set -euo pipefail
# Couleurs pour l'affichage
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Configuration
INSTALL_DIR="/opt/idrac-fan-controller"
SERVICE_NAME="idrac-fan-controller"
CONFIG_FILE="$INSTALL_DIR/config/environment"
echo -e "${RED}=== Désinstallation du contrôleur de ventilateurs Dell iDRAC ===${NC}"
echo
# Vérifier les privilèges root
if [[ $EUID -ne 0 ]]; then
echo -e "${RED}Erreur: Ce script doit être exécuté en tant que root${NC}"
exit 1
fi
# Confirmation
echo -e "${YELLOW}Cette opération va :${NC}"
echo "• Arrêter et désactiver le service $SERVICE_NAME"
echo "• Supprimer tous les fichiers dans $INSTALL_DIR"
echo "• Supprimer le service systemd"
echo "• Supprimer les logs"
echo
echo -e "${RED}ATTENTION: Cette action est irréversible !${NC}"
read -p "Êtes-vous sûr de vouloir continuer ? (yes/NO): " -r
if [[ ! $REPLY =~ ^yes$ ]]; then
echo -e "${GREEN}Désinstallation annulée.${NC}"
exit 0
fi
echo
echo -e "${BLUE}1. Arrêt du service...${NC}"
if systemctl is-active --quiet "$SERVICE_NAME"; then
systemctl stop "$SERVICE_NAME"
echo -e "${GREEN}Service arrêté${NC}"
else
echo -e "${YELLOW}Service déjà arrêté${NC}"
fi
echo -e "${BLUE}2. Désactivation du service...${NC}"
if systemctl is-enabled --quiet "$SERVICE_NAME" 2>/dev/null; then
systemctl disable "$SERVICE_NAME"
echo -e "${GREEN}Service désactivé${NC}"
else
echo -e "${YELLOW}Service déjà désactivé${NC}"
fi
echo -e "${BLUE}3. Suppression du fichier de service systemd...${NC}"
if [ -f "/etc/systemd/system/$SERVICE_NAME.service" ]; then
rm -f "/etc/systemd/system/$SERVICE_NAME.service"
systemctl daemon-reload
echo -e "${GREEN}Fichier de service supprimé${NC}"
else
echo -e "${YELLOW}Fichier de service non trouvé${NC}"
fi
echo -e "${BLUE}4. Sauvegarde de la configuration...${NC}"
if [ -f "$CONFIG_FILE" ]; then
BACKUP_FILE="/tmp/idrac-fan-controller-config-backup-$(date +%Y%m%d-%H%M%S)"
cp "$CONFIG_FILE" "$BACKUP_FILE"
echo -e "${GREEN}Configuration sauvegardée dans: $BACKUP_FILE${NC}"
fi
echo -e "${BLUE}5. Suppression des fichiers d'installation...${NC}"
if [ -d "$INSTALL_DIR" ]; then
rm -rf "$INSTALL_DIR"
echo -e "${GREEN}Répertoire d'installation supprimé${NC}"
else
echo -e "${YELLOW}Répertoire d'installation non trouvé${NC}"
fi
echo -e "${BLUE}6. Suppression des logs...${NC}"
if [ -d "/var/log/$SERVICE_NAME" ]; then
rm -rf "/var/log/$SERVICE_NAME"
echo -e "${GREEN}Logs supprimés${NC}"
else
echo -e "${YELLOW}Répertoire de logs non trouvé${NC}"
fi
echo -e "${BLUE}7. Nettoyage des logs systemd...${NC}"
journalctl --vacuum-time=1d --quiet || true
echo -e "${GREEN}=== Désinstallation terminée avec succès ! ===${NC}"
echo
echo -e "${BLUE}Actions effectuées:${NC}"
echo "• Service $SERVICE_NAME arrêté et désactivé"
echo "• Fichiers d'application supprimés"
echo "• Logs nettoyés"
if [ -f "$BACKUP_FILE" ]; then
echo -e "${YELLOW}• Configuration sauvegardée: $BACKUP_FILE${NC}"
fi
echo
echo -e "${YELLOW}Note: Les ventilateurs sont maintenant contrôlés par le système Dell par défaut${NC}"