From efa7f246982b91c79ef49a5ded0006595572140c Mon Sep 17 00:00:00 2001 From: Ben Kochie Date: Thu, 22 Dec 2022 12:07:37 +0100 Subject: [PATCH] Fix thermal_zone collector noise Add a check for missing/unreadable thermal zone stats and ignore if not availlable. Fixes: https://github.com/prometheus/node_exporter/issues/2552 Signed-off-by: Ben Kochie --- collector/thermal_zone_linux.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/collector/thermal_zone_linux.go b/collector/thermal_zone_linux.go index 6aedf347..6eff2732 100644 --- a/collector/thermal_zone_linux.go +++ b/collector/thermal_zone_linux.go @@ -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" ) @@ -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 }