EP2C602 - IPMI Fan Control


Recommended Posts

I had a major headache trying to get the IPMI Plugin's fan control to work with this motherboard.

 

After a lot of messing, and reading of forums, it appears that this motherboard isn't supported.

 

After more forums however, I managed to write my own bash script to control the CPU and Case Fan speeds based on CPU and Hard Drive temperature.

 

This is my first ever bash script, so I'm sure it's messy and badly written, and full of exploitable holes, but it does the job. It's based off of another script that was written by another forum member, and I have mentioned him in the script. Thanks to his initial efforts, and those of others (also linked in the script) I managed to cobble together the raw IPMI commands that are needed to control fan speeds based on temperatures.

 

I run this as a cron job every minute, and it keeps the server quiet when operating normally, and spins up the fans as needed under load.

 

The reason I needed this on this particular motherboard is because the BIOS Smart Fan setting will set the CPU Fans to 400 RPM regardless of what temperature the CPU is at.

 

I hope this helps. If anyone has questions, I'll do my best to help answer.

 

Also, if this is in the wrong section of the forum, then my apologies, and I'll move to where it's supposed to be!

 

#!/bin/bash
# unraid_array_fan.sh v0.4
# v0.1  First try at it.
# v0.2: Made a small change so the fan speed on low doesn't fluctuate every time the script is run.
# v0.3: It will now enable fan speed change before trying to change it. I missed
#	it at first because pwmconfig was doing it for me while I was testing the fan.
# v0.4: Corrected temp reading to "Temperature_Celsius" as my new Seagate drive
#	was returning two numbers with just "Temperature".
# v0.4.1: Implemented for IPMI on EP2C602. Original Script by xamindar. Many thanks.
#	See https://forums.lime-technology.com/topic/5375-temperature-based-fan-speed-control/
#	Also see http://lime-technology.com/oldforum/index.php?topic=39238.25 for the discovery
#	of the required raw bytes to send using IMPI-Raw.
#
# A simple script to check for the highest hard disk temperatures in an array
# or backplane and then set the fan to an apropriate speed. Fan needs to be connected
# to motherboard with pwm support, not array. Also checks CPU temperatures and sets
# CPU Fan Speeds for motherboards with questionable ability to control it themselves.
#
# DEPENDS ON:grep,awk,smartctl,hdparm,ipmi-raw

### VARIABLES FOR USER TO SET ###
# Amount of drives in the array. Make sure it matches the amount you filled out below.
NUM_DRIVES=4

# unRAID drives that are in the array/backplane of the fan we need to control
HD[1]=/dev/sdb
HD[2]=/dev/sdc
HD[3]=/dev/sdd
HD[4]=/dev/sde

# Temperatures to change fan speed at
# Any temp between OFF and HIGH will cause fan to run on low speed setting 
FAN_MIN_TEMP=30			# Anything between this and 32 - fan is 24. Below this, fan is 16
FAN_LOW_TEMP=35			# Anything between this and 34 - fan is 32
FAN_MID_TEMP=40			# Anything between this and 36 - fan is 48
FAN_HIGH_TEMP=45		# Anything above this - fan is 64

CPU_MIN_TEMP=30		# Anything between this and 35- fan is 24. Below this, fan is 16
CPU_LOW_TEMP=35		# Anything between this and 40 - fan is 32
CPU_MID_TEMP=40		# Anything between this and 45 - fan is 48
CPU_HIGH_TEMP=45	# Anything above this - fan is 64

# IPMI Raw Command to run. For the EP2C602 there are two commands used to set various
# fan speeds. These two commands are both set below. Replace with the appropriate raw
# commands for your MotherBoard.

IPMI_RAW_1="ipmi-raw 00 3a 01"
IPMI_RAW_2="ipmi-raw 00 3a 11"

# IPMI_RAW_1 Format: ipmi-raw 00 3a 01 CPU_1_OVERRIDE CPU_1 REAR_1 FRONT_1 FRONT_2 UNKNOWN
#
# IPMI_RAW_2 Format: ipmi-raw 00 3a 11 CPU_2_OVERRIDE CPU_2 REAR_2 UNKNOWN
#
# IMPI Fan speeds are defined as values between 00 and 64, where 00 is Off, and 64 is Max speed.

### END USER SET VARIABLES ###

# Program variables - do not modify
HIGHEST_TEMP=0
CURRENT_DRIVE=1
CURRENT_TEMP=0

CPU_1_TEMP=0
CPU_2_TEMP=0

CPU_1_OVERRIDE=01
CPU_2_OVERRIDE=01
CPU_1_FAN=32
CPU_2_FAN=32
REAR_FAN=32
FRONT_FAN=32
UNKNOWN_FAN=64

# While loop to get the highest temperature of active drives.
# If all are spun down then high temp will be set to 0.
while [ "$CURRENT_DRIVE" -le "$NUM_DRIVES" ]
do
 SLEEPING=$(hdparm -C ${HD[$CURRENT_DRIVE]} | grep -c standby)
 if [ "$SLEEPING" == "0" ]; then
   CURRENT_TEMP=$(smartctl -d ata -A ${HD[$CURRENT_DRIVE]} | grep -m 1 -i Temperature_Cel | awk '{print $10}')
   if [ "$HIGHEST_TEMP" -le "$CURRENT_TEMP" ]; then
     HIGHEST_TEMP=$CURRENT_TEMP
   fi
 fi
#echo "${HD[$CURRENT_DRIVE]} Temp = $CURRENT_TEMP"
((CURRENT_DRIVE++))
done
#echo "Highest temp is: $HIGHEST_TEMP"

# Get the temperature of CPUs.
CPU_1_TEMP=$(ipmimonitoring | grep 'CPU_AP1' | awk '{print substr($10,0,2)}')
CPU_2_TEMP=$(ipmimonitoring | grep 'CPU_BSP1' | awk '{print substr($10,0,2)}')

#echo "CPU 1 Temp is $CPU_1_TEMP"
#echo "CPU 2 Temp is $CPU_2_TEMP"

# Select Case Fan Speed

if [ "$HIGHEST_TEMP" -lt "$FAN_MIN_TEMP" ]; then
	REAR_FAN=16
	FRONT_FAN=16
elif [ "$HIGHEST_TEMP" -lt "$FAN_LOW_TEMP" ]; then
	REAR_FAN=24
	FRONT_FAN=24
elif [ "$HIGHEST_TEMP" -lt "$FAN_MID_TEMP" ]; then
	REAR_FAN=32
	FRONT_FAN=32
elif [ "$HIGHEST_TEMP" -lt "$FAN_HIGH_TEMP" ]; then
	REAR_FAN=48
	FRONT_FAN=48
else
	REAR_FAN=64
	FRONT_FAN=64
fi

if [ "$HIGHEST_TEMP" -lt 0 ]; then
	REAR_FAN=64
	FRONT_FAN=64
	echo "Something is wrong! - Maximising Fan Speed!!!"
fi

#Select CPU Fan Speed
i=1
while [ $i -le 2 ]
do
	COMBINEDTEMP="CPU_${i}_TEMP"
	COMBINEDFAN="CPU_${i}_FAN"

	if [ "${!COMBINEDTEMP}" -lt "$CPU_MIN_TEMP" ]; then
		eval "$COMBINEDFAN=16"
	elif [ "${!COMBINEDTEMP}" -lt "$CPU_LOW_TEMP" ]; then
		eval "$COMBINEDFAN=24"
	elif [ "${!COMBINEDTEMP}" -lt "$CPU_MID_TEMP" ]; then
		eval "$COMBINEDFAN=32"
	elif [ "${!COMBINEDTEMP}" -lt "$CPU_HIGH_TEMP" ]; then
		eval "$COMBINEDFAN=48"
	else
		eval "$COMBINEDFAN=64"
		FRONT_FAN=64
		REAR_FAN=64
	fi

	if [ "${!COMBINEDTEMP}" -lt 0 ]; then
		eval "$COMBINEDFAN=64"
		echo "Something is wrong! - Maximising Fan Speed!!!"
	fi

	((i++))
	
done

#Send IMPI Commands

CMD="$IPMI_RAW_1 $CPU_1_OVERRIDE $CPU_1_FAN $REAR_FAN $FRONT_FAN $FRONT_FAN $UNKNOWN_FAN"
# echo "IPMI COMMAND ONE: $CMD"
eval $CMD
CMD="$IPMI_RAW_2 $CPU_2_OVERRIDE $CPU_2_FAN $REAR_FAN $UNKNOWN_FAN"
# echo "IPMI COMMAND TWO: $CMD"
eval $CMD

echo "IPMI Fan Control Update Complete."

 

Link to comment
15 hours ago, zzgus said:

Hi @YouAreTheOneNeo I have the same motherboard.

 

I don't exactly understand what are you referring to...

 

 

Doesn't the motherboard control well the fan speeds?

Thankyou

Gus

 

My motherboard is set to Smart Fan but it never changes the fan speed, that's why I wrote the script.

 

I need to check mine, but which BIOS version are you running? I'm wonering if there was an update that perhaps fixed this.

 

Either way, the Case Fans aren't controllable based on temperature as far as I can tell...

Link to comment

Will chech the BIOS version tomorrow but if I'm not wrong is the last bios asrock publised.

 

Are you having any problems with the sata controllers? It's the second time I had a problem with my discs caused by the controllers.

The first time It was recommended to me that I not use the MARVEL SATA CONNECTORS (the four at the right) and the second time a problem with the intel controller.

Had to rebuild one disc. Cross fingers to not happen another time.

Gus

Link to comment
On 22/04/2017 at 4:42 PM, zzgus said:

Will chech the BIOS version tomorrow but if I'm not wrong is the last bios asrock publised.

 

Are you having any problems with the sata controllers? It's the second time I had a problem with my discs caused by the controllers.

The first time It was recommended to me that I not use the MARVEL SATA CONNECTORS (the four at the right) and the second time a problem with the intel controller.

Had to rebuild one disc. Cross fingers to not happen another time.

Gus

 

Yeah I had some issues. They haven't happened since I switched over to the intel chip SAS ports though. Which ones are you using?

Link to comment
  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.