Skip to content

Instantly share code, notes, and snippets.

@ppouliot
Created February 19, 2020 21:25
Show Gist options
  • Save ppouliot/16284f0ebfd35102abee4ed034e90c80 to your computer and use it in GitHub Desktop.
Save ppouliot/16284f0ebfd35102abee4ed034e90c80 to your computer and use it in GitHub Desktop.
Script to set the fan speed on Ampere server
#! /bin/sh
logo () {
echo ""
echo " ▄██▄"
echo " ▄█ █▄"
echo " ▄█ █▄"
echo " ▄▄▄▄█ ▄▄▄ █▄"
echo " ▄█▀▀▀ ▄█ ▀██▄"
echo " ▄█▀ ▄█ ▀█▄"
echo " A M P E R E COMPUTING"
}
display_usage () {
echo ""
echo "Usage: ./setFans.sh auto //Enable Cooling Manager"
echo "Usage: ./setFans.sh N //Set fan PWM to N%"
echo ""
}
set_fan () {
echo -n "Setting fan $1 to "
decPWM=$(printf "%d" $2)
echo -n "$decPWM%. "
fanStat=$(ipmitool raw 0x3C 0x14 $1 $2) #set fan pwm
if [ "$fanStat" = " 00" ]; then
echo "Success"
else
echo "Failed"
fi
}
logo
if [ $# -ne 1 ]; then
display_usage
exit 1
fi
if [ "$1" = "auto" ]; then
#Enable cooling manager
cmStat=$(ipmitool raw 0x3C 0x0B 0x00)
echo -n "Cooling manager "
if [ "$cmStat" = " 00" ]; then
echo "enabled"
echo "Fan speed auto"
else
echo "disabled"
echo "Fan speed manual"
fi
else
#Convert decimal pwm to hex
hexPWM=$(printf "0x%02x" $1)
#Disable cooling manager
cmStat=$(ipmitool raw 0x3C 0x0b 0x01)
echo -n "Cooling manager "
if [ "$cmStat" = " 01" ]; then
echo "disabled"
echo "Fan speed manual"
else
echo "enabled"
echo "Fan speed auto"
fi
sleep 1
#Set the fans
for nFan in {2..6}
do
set_fan $nFan $hexPWM
done
fi
@alexellis
Copy link

@ppouliot I have figured it out!

        for nFan in {2..6}

Needs to be 2..7 - the 7th fan is the one that was being left out and which was causing all the noise.

@alexellis
Copy link

The 2U chassis has 2x fans, the 1U has 7 as per the manual.

Screenshot 2020-10-26 at 10 50 46

Now how do I monitor temperature to make sure the thing doesn't fry?

@rorybolt
Copy link

This script does not appear to work for the 2U Mt Jade platform with firmware 2.10d... any chance for a fix?

@alexellis
Copy link

Hi thanks for the question. There’s no fix because this script is only for its original server.

I got it from Ampere who now have an active developer forum. I’d suggest you ask there

Alex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment