Skip to content

Commit

Permalink
collector/hwmon_linux: handle temperature sensor file which doesn't h…
Browse files Browse the repository at this point in the history
…ave item suffix (prometheus#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 prometheus#1122

Signed-off-by: Paul Gier <pgier@redhat.com>
  • Loading branch information
pgier authored and SuperQ committed Nov 30, 2018
1 parent 7519967 commit 812eda3
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions collector/hwmon_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
Expand Down

0 comments on commit 812eda3

Please sign in to comment.