Thermalzone: return error on empty result

Signed-off-by: Ben Reedy <breed808@breed808.com>
This commit is contained in:
Ben Reedy 2021-09-25 15:21:13 +10:00
parent 5931604b58
commit 5d29ff6497
No known key found for this signature in database
GPG Key ID: 235C15B6086C9D7E

View File

@ -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(