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<index>_<item>"
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 <pgier@redhat.com>
pull/1138/head
Paul Gier 6 years ago committed by Ben Kochie
parent 38163f234f
commit 988f049040

@ -274,6 +274,9 @@ func (c *hwMonCollector) updateHwmon(ch chan<- prometheus.Metric, dir string) er
continue continue
} }
if sensorType == "temp" && element != "type" { if sensorType == "temp" && element != "type" {
if element == "" {
element = "input"
}
desc := prometheus.NewDesc(name+"_celsius", "Hardware monitor for temperature ("+element+")", hwmonLabelDesc, nil) desc := prometheus.NewDesc(name+"_celsius", "Hardware monitor for temperature ("+element+")", hwmonLabelDesc, nil)
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
desc, prometheus.GaugeValue, parsedValue*0.001, labels...) desc, prometheus.GaugeValue, parsedValue*0.001, labels...)

Loading…
Cancel
Save