Skip to content

Instantly share code, notes, and snippets.

@tomaustin700
Created March 20, 2018 11:27
Show Gist options
  • Save tomaustin700/6f56622600b912e58db87f252a626fc0 to your computer and use it in GitHub Desktop.
Save tomaustin700/6f56622600b912e58db87f252a626fc0 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# ----------------------------------------------------------------------------------
# Script for checking the temperature reported by the ambient temperature sensor,
# and if deemed to high send the raw IPMI command to enable dynamic fan control.
#
# Requires ipmitool – apt-get install ipmitool
# Tested on Ubuntu 17.04
# ----------------------------------------------------------------------------------
# IPMI DEFAULT R710 SETTINGS
# Modify to suit your needs.
IPMIHOST=192.168.1.70
IPMIUSER=root
IPMIPW=calvin
# TEMPERATURE
# Change this to the temperature in celcius you are comfortable with.
# If it goes above it will send raw IPMI command to enable dynamic fan control
MAXTEMP=30
# This variable sends a IPMI command to get the temperature, and outputs it as two digits.
# Do not edit unless you know what you do.
TEMP=$(ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW sdr type temperature |grep Ambient |grep degrees |grep -Po '\d{2}' | tail -1)
if [[ $TEMP > $MAXTEMP ]];
then
printf "Temperature is too high! ($TEMP C) Activating dynamic fan control!" | systemd-cat -t R710-IPMI-TEMP
echo "Temperature is too high! ($TEMP C) Activating dynamic fan control!"
ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW raw 0x30 0x30 0x01 0x01
else
ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW raw 0x30 0x30 0x01 0x00
ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW raw 0x30 0x30 0x02 0xff 0x09
printf "Temperature is OK ($TEMP C)" | systemd-cat -t R710-IPMI-TEMP
echo "Temperature is OK ($TEMP C)"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment