mirror of
https://github.com/prometheus/node_exporter.git
synced 2024-11-27 02:53:02 +01:00
* Fix for #945, cpu temperature is signed. Added a type conversion to cpu temperature sysctl. Will still collect/report -1 when the value is -1, this is because it should be up to interpretation whether this is the correct value for the system or not. Some drivers will report -1 for cpu temperature. Other sensors will report "an input into the fan control algorithm", i.e. not the actual temperature, but how much fan it wants. Some people cool their machines with liquid nitrogen. Signed-off-by: Derek Marcotte <554b8425@razorfever.net>
This commit is contained in:
parent
e3cf1d5187
commit
2678d68dcc
@ -138,7 +138,23 @@ func (c *statCollector) Update(ch chan<- prometheus.Metric) error {
|
||||
}
|
||||
continue
|
||||
}
|
||||
ch <- c.temp.mustNewConstMetric(float64(temp-2732)/10, lcpu)
|
||||
|
||||
// Temp is a signed integer in deci-degrees Kelvin.
|
||||
// Cast uint32 to int32 and convert to float64 degrees Celsius.
|
||||
//
|
||||
// 2732 is used as the conversion constant for deci-degrees
|
||||
// Kelvin, in multiple places in the kernel that feed into this
|
||||
// sysctl, so we want to maintain consistency:
|
||||
//
|
||||
// sys/dev/amdtemp/amdtemp.c
|
||||
// #define AMDTEMP_ZERO_C_TO_K 2732
|
||||
//
|
||||
// sys/dev/acpica/acpi_thermal.c
|
||||
// #define TZ_ZEROC 2732
|
||||
//
|
||||
// sys/dev/coretemp/coretemp.c
|
||||
// #define TZ_ZEROC 2732
|
||||
ch <- c.temp.mustNewConstMetric(float64(int32(temp)-2732)/10, lcpu)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user