mirror of
https://github.com/fankes/beszel.git
synced 2025-10-19 09:49:28 +08:00
check for malformed sensor names on darwin (#796)
This commit is contained in:
@@ -6,8 +6,10 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"path"
|
"path"
|
||||||
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"unicode/utf8"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v4/common"
|
"github.com/shirou/gopsutil/v4/common"
|
||||||
"github.com/shirou/gopsutil/v4/sensors"
|
"github.com/shirou/gopsutil/v4/sensors"
|
||||||
@@ -103,6 +105,11 @@ func (a *Agent) updateTemperatures(systemStats *system.Stats) {
|
|||||||
|
|
||||||
systemStats.Temperatures = make(map[string]float64, len(temps))
|
systemStats.Temperatures = make(map[string]float64, len(temps))
|
||||||
for i, sensor := range temps {
|
for i, sensor := range temps {
|
||||||
|
// check for malformed strings on darwin (gopsutil/issues/1832)
|
||||||
|
if runtime.GOOS == "darwin" && !utf8.ValidString(sensor.SensorKey) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
// scale temperature
|
// scale temperature
|
||||||
if sensor.Temperature != 0 && sensor.Temperature < 1 {
|
if sensor.Temperature != 0 && sensor.Temperature < 1 {
|
||||||
sensor.Temperature = scaleTemperature(sensor.Temperature)
|
sensor.Temperature = scaleTemperature(sensor.Temperature)
|
||||||
|
Reference in New Issue
Block a user