Skip to content

Instantly share code, notes, and snippets.

@mikhailbot
Last active September 21, 2021 01:38
Show Gist options
  • Save mikhailbot/f739a7d6415772f2b790ada136b7b9ae to your computer and use it in GitHub Desktop.
Save mikhailbot/f739a7d6415772f2b790ada136b7b9ae to your computer and use it in GitHub Desktop.
R720 Fan Control
#!/bin/bash
# IPMI SETTINGS:
# Modify to suit your needs.
IPMIHOST=10.0.0.1
IPMIUSER=root
IPMIPW=calvin
IPMIEK=0000000000000000000000000000000000000000
# TEMPERATURE
# Change this to the temperature in celcius you are comfortable with.
# If the temperature goes above the set degrees it will send raw IPMI command to enable dynamic fan control
MAXTEMP=60
# This variable sends a IPMI command to get the temperature, and outputs it as two digits.
TEMP=$(ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW -y $IPMIEK sdr type temperature | grep -vi inlet | grep -vi exhaust | grep -Po '\d{2}' | sort -r | head -n 1)
if [[ $TEMP > $MAXTEMP ]];
then
echo "Warning: Temperature is too high! Activating dynamic fan control! ($TEMP C)"
ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW -y $IPMIEK raw 0x30 0x30 0x01 0x01
else
echo "Temperature is OK ($TEMP C)"
ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW -y $IPMIEK raw 0x30 0x30 0x01 0x00
ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW -y $IPMIEK raw 0x30 0x30 0x02 0xff 0x0a
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment