Skip to content

Commit

Permalink
Fix thermal_zone collector noise
Browse files Browse the repository at this point in the history
Add a check for missing/unreadable thermal zone stats and ignore if not
availlable.

Fixes: #2552

Signed-off-by: Ben Kochie <[email protected]>
  • Loading branch information
SuperQ committed Dec 22, 2022
1 parent 4484f18 commit efa7f24
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions collector/thermal_zone_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@
package collector

import (
"errors"
"fmt"
"os"

"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/procfs/sysfs"
)
Expand Down Expand Up @@ -70,6 +73,10 @@ func NewThermalZoneCollector(logger log.Logger) (Collector, error) {
func (c *thermalZoneCollector) Update(ch chan<- prometheus.Metric) error {
thermalZones, err := c.fs.ClassThermalZoneStats()
if err != nil {
if errors.Is(err, os.ErrNotExist) || errors.Is(err, os.ErrPermission) || errors.Is(err, os.ErrInvalid) {
level.Debug(c.logger).Log("msg", "Could not read thermal zone stats", "err", err)
return ErrNoData
}
return err
}

Expand Down

0 comments on commit efa7f24

Please sign in to comment.