From ff532561db4fab9e9075ffe420916a6a2651df70 Mon Sep 17 00:00:00 2001 From: miliacristian Date: Tue, 16 Apr 2024 18:23:34 +0200 Subject: [PATCH] Update class_thermal.go Sum-up: ignore invalid thermal zones to avoid discharding of all thermal zone metric Some thermal zones generates errors fs.PathError causing the lost of all metric data also for valid thermal zone. Example of error log: ts=2024-04-10T14:23:57.064Z caller=collector.go:169 level=error msg="collector failed" name=thermal_zone duration_seconds=0.053034792 err="read /sys/class/thermal/thermal_zone24/temp: invalid argument" Signed-off-by: miliacristian --- sysfs/class_thermal.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sysfs/class_thermal.go b/sysfs/class_thermal.go index 0935a21ca..ab9048f53 100644 --- a/sysfs/class_thermal.go +++ b/sysfs/class_thermal.go @@ -24,6 +24,7 @@ import ( "syscall" "github.com/prometheus/procfs/internal/util" + fsp "io/fs" ) // ClassThermalZoneStats contains info from files in /sys/class/thermal/thermal_zone @@ -49,7 +50,7 @@ func (fs FS) ClassThermalZoneStats() ([]ClassThermalZoneStats, error) { for _, zone := range zones { zoneStats, err := parseClassThermalZone(zone) if err != nil { - if errors.Is(err, syscall.ENODATA) { + if errors.Is(err, syscall.ENODATA) || errors.As(err, new(*fsp.PathError)) { continue } return nil, err