修复部分设备读取温度失败导致的忽略全部设备温度问题

This commit is contained in:
yii committed 2025-12-09 16:21:45 +08:00
1 parent 524dbe65e6
commit 3c99526fc6
1 file changed
+1 -1
+1 -1
View File
@@ -22,7 +22,7 @@ func NewTemperatureCollector() *TemperatureCollector {
func (t *TemperatureCollector) Collect() ([]*protocol.TemperatureData, error) {
// 使用 gopsutil 的 sensors 包采集温度数据
temps, err := sensors.TemperaturesWithContext(context.Background())
if err != nil {
if err != nil && len(temps) == 0 {
// 如果获取失败,返回空数组(某些系统可能不支持)
return []*protocol.TemperatureData{}, nil
}