fix system info metric crash on error

This commit is contained in:
yusing 2025-02-14 06:11:13 +08:00
parent 5b1d45a8fe
commit 7047d37f70

View file

@ -101,7 +101,7 @@ func getSystemInfo(ctx context.Context, lastResult *SystemInfo) (*SystemInfo, er
// disk.Warnings has the same type // disk.Warnings has the same type
// all Warnings are alias of common.Warnings from "github.com/shirou/gopsutil/v4/internal/common" // all Warnings are alias of common.Warnings from "github.com/shirou/gopsutil/v4/internal/common"
// see line 37 // see line 37
var warnings sensors.Warnings warnings := new(sensors.Warnings)
if errors.As(err, &warnings) { if errors.As(err, &warnings) {
for _, warning := range warnings.List { for _, warning := range warnings.List {
allWarnings.Add(warning) allWarnings.Add(warning)