From 988f049040abd6136a6209727b2166de1a04db6a Mon Sep 17 00:00:00 2001 From: Paul Gier Date: Tue, 30 Oct 2018 12:49:22 -0500 Subject: [PATCH] collector/hwmon_linux: handle temperature sensor file which doesn't have item suffix (#1123) In some cases the file might be called "temp" instead of the usual format "temp_" as described in the kernel docs: https://www.kernel.org/doc/Documentation/hwmon/sysfs-interface In this case, treat this as an _input file containing the current temperature reading. Fixes #1122 Signed-off-by: Paul Gier --- collector/hwmon_linux.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/collector/hwmon_linux.go b/collector/hwmon_linux.go index b2c40d56..d5c1de63 100644 --- a/collector/hwmon_linux.go +++ b/collector/hwmon_linux.go @@ -274,6 +274,9 @@ func (c *hwMonCollector) updateHwmon(ch chan<- prometheus.Metric, dir string) er continue } if sensorType == "temp" && element != "type" { + if element == "" { + element = "input" + } desc := prometheus.NewDesc(name+"_celsius", "Hardware monitor for temperature ("+element+")", hwmonLabelDesc, nil) ch <- prometheus.MustNewConstMetric( desc, prometheus.GaugeValue, parsedValue*0.001, labels...)