#2159·gopsutil

sensors: implement TemperaturesWithContext on FreeBSD (dev.cpu.N.temperature, hw.acpi.thermal)

Author: flying-turtle-63Created Sep 24, 2026Updated Sep 24, 2026

Describe the feature

On FreeBSD, sensors.TemperaturesWithContext is a stub (sensors/sensors_freebsd.go):

go
func TemperaturesWithContext(_ context.Context) ([]TemperatureStat, error) {
	return []TemperatureStat{}, common.ErrNotImplementedError
}

As a result, tools built on gopsutil (for example the Beszel agent) report no temperature at all on FreeBSD-based systems such as OPNsense and pfSense, even though the kernel exposes the values.

What FreeBSD provides

FreeBSD already publishes temperatures as sysctls, which could be read with unix.SysctlUint32 / sysctlbyname:

Source Sysctl Notes
coretemp(4) (Intel) / amdtemp(4) (AMD) dev.cpu.N.temperature one per CPU; dev.cpu.N.coretemp.tjmax gives the critical value
acpi_thermal(4) hw.acpi.thermal.tzN.temperature thermal zones; _CRT / _HOT give the critical/high values (-1 when unset)

These sysctls have the IK format: an integer in tenths of a kelvin. The Celsius value is (v - 2731) / 10.0. sysctl(8) prints them already converted.

This is on FreeBSD 15.1-RELEASE amd64 (OPNsense 26.7, Intel N150, coretemp loaded):

$ sysctl dev.cpu.0.temperature dev.cpu.0.coretemp.tjmax hw.acpi.thermal.tz0.temperature hw.acpi.thermal.tz0._CRT
dev.cpu.0.temperature: 47.0C
dev.cpu.0.coretemp.tjmax: 105.0C
hw.acpi.thermal.tz0.temperature: 27.9C
hw.acpi.thermal.tz0._CRT: 110.1C
$ sysctl -t dev.cpu.0.temperature hw.acpi.thermal.tz0.temperature
dev.cpu.0.temperature: integer
hw.acpi.thermal.tz0.temperature: integer

Suggested behaviour

  • Walk dev.cpu.0..hw.ncpu-1 and hw.acpi.thermal.tz0.., stopping at the first missing index.
  • Return one TemperatureStat per sensor found, with a SensorKey such as cpuN / acpi_tzN and Critical taken from tjmax / _CRT when present.
  • Skip sensors that are absent, for example when coretemp is not loaded.
  • Return ErrNotImplementedError only when no sensor exists at all.

I'm happy to test a patch on real hardware.