Monitoring CPUs temperature instead of inlet temperature

This commit is contained in:
tigerblue77 2022-04-12 16:13:03 +02:00
parent d3e4040e56
commit d65d64b303
4 changed files with 37 additions and 14 deletions

View File

@ -26,6 +26,6 @@ ENV IDRAC_HOST local
#ENV IDRAC_USER root #ENV IDRAC_USER root
#ENV IDRAC_PASSWORD calvin #ENV IDRAC_PASSWORD calvin
ENV FAN_SPEED 5 ENV FAN_SPEED 5
ENV MAXIMUM_TEMPERATURE 32 ENV CPU_TEMPERATURE_TRESHOLD 50
CMD /startup.sh && /opt/check_temp.sh && cron && tail -f /var/log/cron.log CMD /startup.sh && /opt/check_temp.sh && cron && tail -f /var/log/cron.log

View File

@ -4,7 +4,7 @@
- `IDRAC_USERNAME` parameter is only necessary if you're adressing a distant iDRAC. Default value is "root". - `IDRAC_USERNAME` parameter is only necessary if you're adressing a distant iDRAC. Default value is "root".
- `IDRAC_PASSWORD` parameter is only necessary if you're adressing a distant iDRAC. Default value is "calvin". - `IDRAC_PASSWORD` parameter is only necessary if you're adressing a distant iDRAC. Default value is "calvin".
- `FAN_SPEED` parameter can be set as a decimal (from 0 to 100%) or hexadecimal value (from 0x00 to 0x64) you want to set the fans to. Default value is 5(%). - `FAN_SPEED` parameter can be set as a decimal (from 0 to 100%) or hexadecimal value (from 0x00 to 0x64) you want to set the fans to. Default value is 5(%).
- `MAXIMUM_TEMPERATURE` parameter is the 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 32(°C). - `CPU_TEMPERATURE_TRESHOLD` 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).
To use: To use:
@ -15,7 +15,7 @@ docker run -d \
--name Dell_iDRAC_fan_controller \ --name Dell_iDRAC_fan_controller \
--restart unless-stopped \ --restart unless-stopped \
-e FAN_SPEED=<dec or hex fan speed> \ -e FAN_SPEED=<dec or hex fan speed> \
-e MAXIMUM_TEMPERATURE=<dec temp treshold> \ -e CPU_TEMPERATURE_TRESHOLD=<dec temp treshold> \
alombardo4/idrac-fan-control:latest alombardo4/idrac-fan-control:latest
``` ```
@ -29,7 +29,7 @@ docker run -d \
-e IDRAC_USERNAME=<iDRAC username> \ -e IDRAC_USERNAME=<iDRAC username> \
-e IDRAC_PASSWORD=<iDRAC password> \ -e IDRAC_PASSWORD=<iDRAC password> \
-e FAN_SPEED=<dec or hex fan speed> \ -e FAN_SPEED=<dec or hex fan speed> \
-e MAXIMUM_TEMPERATURE=<dec temp treshold> \ -e CPU_TEMPERATURE_TRESHOLD=<dec temp treshold> \
alombardo4/idrac-fan-control:latest alombardo4/idrac-fan-control:latest
``` ```
@ -48,7 +48,7 @@ services:
environment: environment:
- IDRAC_HOST=local # can be omitted as it is the default value - IDRAC_HOST=local # can be omitted as it is the default value
- FAN_SPEED=0x05 # set to the decimal or hexadecimal value you want to set the fans to (from 0 to 100%) - FAN_SPEED=0x05 # set to the decimal or hexadecimal value you want to set the fans to (from 0 to 100%)
- MAXIMUM_TEMPERATURE=<dec temp treshold> - CPU_TEMPERATURE_TRESHOLD=<dec temp treshold>
devices: devices:
- /dev/ipmi0:/dev/ipmi0 - /dev/ipmi0:/dev/ipmi0
``` ```
@ -68,5 +68,5 @@ services:
- IDRAC_USERNAME=root # set to your IPMI username - IDRAC_USERNAME=root # set to your IPMI username
- IDRAC_PASSWORD=calvin # set to your IPMI password - IDRAC_PASSWORD=calvin # set to your IPMI password
- FAN_SPEED=0x05 # set to the decimal or hexadecimal value you want to set the fans to (from 0 to 100%) - FAN_SPEED=0x05 # set to the decimal or hexadecimal value you want to set the fans to (from 0 to 100%)
- MAXIMUM_TEMPERATURE=<dec temp treshold> - CPU_TEMPERATURE_TRESHOLD=<dec temp treshold>
``` ```

View File

@ -5,7 +5,8 @@ IPMI_USERNAME=`cat /idrac_username.txt`
IPMI_PASSWORD=`cat /idrac_password.txt` IPMI_PASSWORD=`cat /idrac_password.txt`
DECIMAL_FAN_SPEED=`cat /decimal_fan_speed.txt` DECIMAL_FAN_SPEED=`cat /decimal_fan_speed.txt`
HEXADECIMAL_FAN_SPEED=`cat /hexadecimal_fan_speed.txt` HEXADECIMAL_FAN_SPEED=`cat /hexadecimal_fan_speed.txt`
MAXIMUM_INLET_TEMPERATURE=`cat /maximum_inlet_temperature.txt` CPU_TEMPERATURE_TRESHOLD=`cat /cpu_temperature_treshold.txt`
readonly DELL_FRESH_AIR_COMPLIANCE=45
if [[ $IPMI_HOST == "local" ]] if [[ $IPMI_HOST == "local" ]]
then then
@ -14,20 +15,42 @@ else
LOGIN_STRING="lanplus -H $IPMI_HOST -U $IPMI_USERNAME -P $IPMI_PASSWORD" LOGIN_STRING="lanplus -H $IPMI_HOST -U $IPMI_USERNAME -P $IPMI_PASSWORD"
fi fi
INLET_TEMPERATURE=$(ipmitool -I $LOGIN_STRING sdr type temperature |grep Inlet |grep degrees |grep -Po '\d{2}' | tail -1) DATA=$(ipmitool -I $LOGIN_STRING sdr type temperature | grep degrees)
INLET_TEMPERATURE=$(echo "$DATA" | grep Inlet | grep -Po '\d{2}' | tail -1)
EXHAUST_TEMPERATURE=$(echo "$DATA" | grep Exhaust | grep -Po '\d{2}' | tail -1)
CPU_DATA=$(echo "$DATA" | grep "3\." | grep -Po '\d{2}')
CPU1_TEMPERATURE=$(echo $CPU_DATA | awk '{print $1;}')
CPU2_TEMPERATURE=$(echo $CPU_DATA | awk '{print $2;}')
RED='\033[0;31m' RED='\033[0;31m'
GREEN='\033[0;32m' GREEN='\033[0;32m'
NC='\033[0m' # No Color NC='\033[0m' # No Color
echo "------------------------------------" echo "------------------------------------"
echo "Current inlet temperature is $INLET_TEMPERATURE °C." echo "Current"
if [ $INLET_TEMPERATURE -gt $MAXIMUM_INLET_TEMPERATURE ] echo "- inlet temperature is $INLET_TEMPERATURE°C"
echo "- CPU 1 temperature is $CPU1_TEMPERATURE°C"
echo "- CPU 2 temperature is $CPU2_TEMPERATURE°C"
echo "- Exhaust temperature is $EXHAUST_TEMPERATURE°C"
CPU1_OVERHEAT () { [ $CPU1_TEMPERATURE -gt $CPU_TEMPERATURE_TRESHOLD ]; }
CPU2_OVERHEAT () { [ $CPU2_TEMPERATURE -gt $CPU_TEMPERATURE_TRESHOLD ]; }
if CPU1_OVERHEAT
then then
printf "Inlet temperature is ${RED}too high${NC}. Activating default dynamic fan control." if CPU2_OVERHEAT
then
printf "CPU 1 and CPU 2 temperatures are ${RED}too high${NC}. Activating default dynamic fan control."
else
printf "CPU 1 temperature is ${RED}too high${NC}. Activating default dynamic fan control."
fi
ipmitool -I $LOGIN_STRING raw 0x30 0x30 0x01 0x01
elif CPU2_OVERHEAT
then
printf "CPU 2 temperature is ${RED}too high${NC}. Activating default dynamic fan control."
ipmitool -I $LOGIN_STRING raw 0x30 0x30 0x01 0x01 ipmitool -I $LOGIN_STRING raw 0x30 0x30 0x01 0x01
else else
printf "Inlet temperature is ${GREEN}OK${NC}. Using manual fan control with ${DECIMAL_FAN_SPEED}%% fan speed." printf "CPUs temperatures are ${GREEN}OK${NC}. Using manual fan control with ${DECIMAL_FAN_SPEED}%% fan speed."
ipmitool -I $LOGIN_STRING raw 0x30 0x30 0x01 0x00 ipmitool -I $LOGIN_STRING raw 0x30 0x30 0x01 0x00
ipmitool -I $LOGIN_STRING raw 0x30 0x30 0x02 0xff $HEXADECIMAL_FAN_SPEED ipmitool -I $LOGIN_STRING raw 0x30 0x30 0x02 0xff $HEXADECIMAL_FAN_SPEED
fi fi

View File

@ -15,7 +15,7 @@ fi
echo $DECIMAL_FAN_SPEED >> /decimal_fan_speed.txt echo $DECIMAL_FAN_SPEED >> /decimal_fan_speed.txt
echo $HEXADECIMAL_FAN_SPEED >> /hexadecimal_fan_speed.txt echo $HEXADECIMAL_FAN_SPEED >> /hexadecimal_fan_speed.txt
echo $MAXIMUM_TEMPERATURE >> /maximum_inlet_temperature.txt echo $CPU_TEMPERATURE_TRESHOLD >> /cpu_temperature_treshold.txt
echo "Idrac/IPMI host: `cat /idrac_host.txt`" echo "Idrac/IPMI host: `cat /idrac_host.txt`"
if [[ $IDRAC_HOST != "local" ]] if [[ $IDRAC_HOST != "local" ]]
@ -24,4 +24,4 @@ then
echo "Idrac/IPMI password: `cat /idrac_password.txt`" echo "Idrac/IPMI password: `cat /idrac_password.txt`"
fi fi
echo "Fan speed objective: `cat /decimal_fan_speed.txt`%" echo "Fan speed objective: `cat /decimal_fan_speed.txt`%"
echo "Maximum inlet temperature: `cat /maximum_inlet_temperature.txt`°C" echo "CPU temperature treshold: `cat /cpu_temperature_treshold.txt`°C"