das_fanctl.sh reads drive temps via smartctl (falling back to the EMM backplane sensors), interpolates a fan percentage, and re-sends _shutup on a 5s keepalive so the shelf does not revert to full speed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
106 lines
3.6 KiB
Bash
Executable File
106 lines
3.6 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# https://github.com/brezlord/iDRAC7_fan_control
|
|
# Modified by Zeb Hering
|
|
# A simple script to control fan speeds on Dell generation 12 PowerEdge servers.
|
|
# If the inlet temperature is above $TEMP_THRESHOLD C enable iDRAC dynamic control and exit program.
|
|
# If inlet temp is below $TEMP_THRESHOLD C set fan control to manual and set fan speed to predetermined value.
|
|
# The tower servers T320, T420 & T620 inlet temperature sensor is after the HDDs so temperature will
|
|
# be higher than the ambient temperature.
|
|
|
|
# Variables
|
|
IDRAC_IP="10.1.1.251"
|
|
IDRAC_USER="root"
|
|
IDRAC_PASSWORD="*^b#!efRhE8qULqUCa4U"
|
|
# Fan speed in %
|
|
SPEED0="0x00"
|
|
SPEED5="0x05"
|
|
SPEED10="0x0a"
|
|
SPEED15="0x0f"
|
|
SPEED20="0x14"
|
|
SPEED25="0x19"
|
|
SPEED30="0x1e"
|
|
SPEED35="0x23"
|
|
TEMP_THRESHOLD="65" # iDRAC dynamic control enable threshold
|
|
TEMP_SENSOR="0Eh" # CPU 1 Temp
|
|
TEMP_SENSOR="0Fh" # CPU 2 Temp
|
|
SENSOR_NAME="Sensor"
|
|
|
|
if [ "$TEMP_SENSOR" == "04h" ]
|
|
then
|
|
SENSOR_NAME="Inlet"
|
|
elif [ "$TEMP_SENSOR" == "01h" ]
|
|
then
|
|
SENSOR_NAME="Exhaust"
|
|
elif [ "$TEMP_SENSOR" == "0Eh" ]
|
|
then
|
|
SENSOR_NAME="CPU1"
|
|
elif [ "$TEMP_SENSOR" == "0Fh" ]
|
|
then
|
|
SENSOR_NAME="CPU2"
|
|
fi
|
|
|
|
# Get system date & time.
|
|
DATE=$(date +%d-%m-%Y\ %H:%M:%S)
|
|
echo "Date $DATE"
|
|
|
|
# Get temperature from iDRAC for CPU1 and CPU2.
|
|
T_CPU1=$(ipmitool -I lanplus -H $IDRAC_IP -U $IDRAC_USER -P $IDRAC_PASSWORD sdr type temperature | grep "0Eh" | cut -d"|" -f5 | cut -d" " -f2)
|
|
T_CPU2=$(ipmitool -I lanplus -H $IDRAC_IP -U $IDRAC_USER -P $IDRAC_PASSWORD sdr type temperature | grep "0Fh" | cut -d"|" -f5 | cut -d" " -f2)
|
|
|
|
echo "--> iDRAC IP Address: $IDRAC_IP"
|
|
echo "--> Current CPU1 Temp: $T_CPU1"
|
|
echo "--> Current CPU2 Temp: $T_CPU2"
|
|
|
|
# Compare the temperatures of CPU1 and CPU2 and set $T to the hotter one.
|
|
if [ $(echo "$T_CPU1 > $T_CPU2" | bc) -eq 1 ]; then
|
|
T=$T_CPU1
|
|
SENSOR_NAME="CPU1"
|
|
else
|
|
T=$T_CPU2
|
|
SENSOR_NAME="CPU2"
|
|
fi
|
|
|
|
echo "--> Hottest Sensor: $SENSOR_NAME - Temp: $T"
|
|
|
|
# If ambient temperature is above $TEMP_THRESHOLD C enable dynamic control and exit, if below set manual control.
|
|
if [[ $T > $TEMP_THRESHOLD ]]
|
|
then
|
|
echo "--> Temperature is above Dynamic Threshold - $TEMP_THRESHOLD C"
|
|
echo "--> Enabled dynamic fan control"
|
|
ipmitool -I lanplus -H $IDRAC_IP -U $IDRAC_USER -P $IDRAC_PASSWORD raw 0x30 0x30 0x01 0x01
|
|
exit 1
|
|
else
|
|
echo "--> Temperature is below Dynamic Threshold - $TEMP_THRESHOLD C"
|
|
echo "--> Disabled dynamic fan control"
|
|
ipmitool -I lanplus -H $IDRAC_IP -U $IDRAC_USER -P $IDRAC_PASSWORD raw 0x30 0x30 0x01 0x00
|
|
fi
|
|
|
|
# Set fan speed dependant on ambient temperature if inlet temperaturte is below $TEMP_THRESHOLD C.
|
|
# If inlet temperature between 0 and 30deg C then set fans to 10%.
|
|
if [ "$T" -ge 0 ] && [ "$T" -le 30 ]
|
|
then
|
|
echo "--> Setting fan speed to 10%"
|
|
ipmitool -I lanplus -H $IDRAC_IP -U $IDRAC_USER -P $IDRAC_PASSWORD raw 0x30 0x30 0x02 0xff $SPEED10
|
|
|
|
# If inlet temperature between 35 and 40deg C then set fans to 15%
|
|
elif [ "$T" -ge 35 ] && [ "$T" -le 40 ]
|
|
then
|
|
echo "--> Setting fan speed to 15%"
|
|
ipmitool -I lanplus -H $IDRAC_IP -U $IDRAC_USER -P $IDRAC_PASSWORD raw 0x30 0x30 0x02 0xff $SPEED15
|
|
|
|
# If inlet temperature between 40 and 50deg C then set fans to 20%
|
|
elif [ "$T" -ge 40 ] && [ "$T" -le 50 ]
|
|
then
|
|
echo "--> Setting fan speed to 20%"
|
|
ipmitool -I lanplus -H $IDRAC_IP -U $IDRAC_USER -P $IDRAC_PASSWORD raw 0x30 0x30 0x02 0xff $SPEED20
|
|
|
|
# If inlet temperature between 55 and $TEMP_THRESHOLD C then set fans to 25%
|
|
elif [ "$T" -ge 51 ] && [ "$T" -le $TEMP_THRESHOLD ]
|
|
then
|
|
echo "--> Setting fan speed to 25%"
|
|
ipmitool -I lanplus -H $IDRAC_IP -U $IDRAC_USER -P $IDRAC_PASSWORD raw 0x30 0x30 0x02 0xff $SPEED25
|
|
fi
|
|
|
|
|