Skip to content

Commit

Permalink
Update class_thermal.go (#634)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
miliacristian authored May 14, 2024
1 parent ae2937e commit dbe3261
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion sysfs/class_thermal.go
Original file line number Diff line number Diff line change
Expand Up @@ -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<zone>
Expand All @@ -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
Expand Down

0 comments on commit dbe3261

Please sign in to comment.