From 5d29ff64970113c3ac7f53982936e4b1c7e23047 Mon Sep 17 00:00:00 2001 From: Ben Reedy Date: Sat, 25 Sep 2021 15:21:13 +1000 Subject: [PATCH] Thermalzone: return error on empty result Signed-off-by: Ben Reedy --- collector/thermalzone.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/collector/thermalzone.go b/collector/thermalzone.go index c76cdf84..3629d473 100644 --- a/collector/thermalzone.go +++ b/collector/thermalzone.go @@ -1,6 +1,8 @@ package collector import ( + "errors" + "github.com/StackExchange/wmi" "github.com/prometheus-community/windows_exporter/log" "github.com/prometheus/client_golang/prometheus" @@ -75,6 +77,11 @@ func (c *thermalZoneCollector) collect(ch chan<- prometheus.Metric) (*prometheus return nil, err } + // ThermalZone collector has been known to 'successfully' return an empty result. + if len(dst) == 0 { + return nil, errors.New("Empty results set for collector") + } + for _, info := range dst { //Divide by 10 and subtract 273.15 to convert decikelvin to celsius ch <- prometheus.MustNewConstMetric(