Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion collector/cpu_freebsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}