前言

作为企业级的服务器,风扇的噪声是非常大,放在家中隔着房间都让人难以接受,好在风扇都是无刷电机,我们可以自由调整转速

获取温度

iDRAC并没有找到合适的API,所以我们通过装一台虚拟机或PVE SHELL内直接获取

apt-get install lm-sensors

# 获取传感器信息
sensors-detect

我们只取CPU最高温度就好

sensors|grep high|cut -d "+" -f2|cut -d "." -f1|sort -nr|sed -n 1p

调整风扇速度

这里我们用到ipmitool这个工具

apt-get install ipmitool

首先需要将风扇设置为手动模式,不然设置速度后会马上被重置

ipmitool -I lanplus -H $host -U $user -P $password raw 0x30 0x30 0x01 0x00 >> /dev/null

将风扇设置为19%

ipmitool -I lanplus -H $host -U $user -P $password raw 0x30 0x30 0x02 0xff 0x13 >> /dev/null

我们只需要调整最后一位0x13就可以控制风扇的百分比,注意此处是16进制

执行脚本

由于气温不断的变化,单一的转速并不能带来良好的散热,所以我们可以设置几个阶段,不同温度,使用不同的转速来散热,避免CPU过热

#!/bin/bash

# Read the max CPU temp from sensors (lm-sensor) 
tempCpu=$(sensors|grep "high"|cut -d "+" -f2|cut -d "." -f1|sort -nr|sed -n 1p)
# Define CPU limie

# Set variables

host="idrac_ip"
user="idrac_user"
password="idrac_password"

minCpu="50"
medCpu="56"
maxCpu="61"

if [ $tempCpu -le $minCpu ] ; then

	ipmitool -I lanplus -H $host -U $user -P $password raw 0x30 0x30 0x01 0x00 >> /dev/null
	ipmitool -I lanplus -H $host -U $user -P $password raw 0x30 0x30 0x02 0xff 0x13 >> /dev/null

elif [ $tempCpu -le $medCpu ] ; then

	ipmitool -I lanplus -H $host -U $user -P $password raw 0x30 0x30 0x01 0x00 >> /dev/null
	ipmitool -I lanplus -H $host -U $user -P $password raw 0x30 0x30 0x02 0xff 0x17 >> /dev/null

elif [ $tempCpu -le $maxCpu ] ; then

	ipmitool -I lanplus -H $host -U $user -P $password raw 0x30 0x30 0x01 0x00 >> /dev/null
	ipmitool -I lanplus -H $host -U $user -P $password raw 0x30 0x30 0x02 0xff 0x20 >> /dev/null

else
	# Let the server decide
	ipmitool -I lanplus -H $host -U $user -P $password raw 0x30 0x30 0x01 0x01 >> /dev/null

fi

最后

将脚本设为定时执行就好,转速可根据实际情况自行调整,从此整个世界都安静了

R710[1],R720等型号同样适用


  1. R710 quieter ↩︎