Skip to content

Commit

Permalink
Update class_thermal.go (prometheus#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 <miliacristian4@gmail.com>
  • Loading branch information
miliacristian authored and jritter committed Jul 15, 2024
1 parent 93c9b5a commit 96e509a
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 96e509a

Please sign in to comment.