FreeBSD CPU温度检测
我在FreeBSD系统中尝试通过PCI Passthrough方式在 bhyve(BSD hypervisor) Linux虚拟机中使用 Nvidia Tesla P4 GPU运算卡 ,但是改装风扇散热不确定是否能够满足要求。所以,我尝试监控主机的温度和散热风扇的转速,以及调整风扇转速的方法。
这里汇总FreeBSD的CPU温度检测方法,并一一实践来对比最佳方案。
coretemp
模块
FreeBSD内核驱动模块 coretemp
加载以后就能够通过 sysctl
获取CPU温度,方法如下:
加载CPU temp模块,需要针对Intel / AMD 处理器分别加载不同模块:
加载CPU temp模块
# Intel 处理器加载 coretemp 模块
kldload -v coretemp
# AMD 处理器加载 amdtemp 模块
kldload -v amdtemp
通过
sysctl
获取CPU问题:
获取CPU温度
sysctl -a | grep temperature
在我的 Intel Xeon E-2274G 有如下输出案例:
获取CPU温度
hw.acpi.thermal.tz0.temperature: 27.9C
dev.pchtherm.0.temperature: 53.0C
dev.cpu.7.temperature: 48.0C
dev.cpu.5.temperature: 30.0C
dev.cpu.3.temperature: 36.0C
dev.cpu.1.temperature: 33.0C
dev.cpu.6.temperature: 35.0C
dev.cpu.4.temperature: 31.0C
dev.cpu.2.temperature: 35.0C
dev.cpu.0.temperature: 33.0C
如果要在启动时加载temp模块,则修订
/boot/loader.conf
添加:
设置启动时加载temp内核模块
# Intel 处理器设置加载 coretemp
coretemp_load="YES"
# AMD 处理器设置加载 amdtemp
amdtemp_load="YES"
IPMI工具ipmitool
如果硬件支持 ipmitool
,则通过 sensor
子命令可以获得服务器的传感器问题:
通过 sensor 获取服务器温度
# 加载ipmi模块
kldload ipmi
# 检查传感器温度
ipmitool sensor
不过,如果主机没有支持IPMI硬件,则会出现报错:
通过 sensor 获取服务器温度报错,原因是没有IPMI支持
Could not open device at /dev/ipmi0 or /dev/ipmi/0 or /dev/ipmidev/0: No such file or directory
备注
如果服务器是Supermicro硬件, bsdhwmon
工具可以提供硬件传感器监控。参见 GitHub: koitsu/bsdhwmon (该工具在FreeBSD发行版提供,可以通过 pkg
安装)