henrygd/beszel · warning

panic: %v

Error message

panic: %v

What it means

The agent wraps gopsutil's sensors.TemperaturesWithContext in a panic-recovering helper because gopsutil can panic while parsing sensor data (gopsutil issue #1832). This error converts that panic into a normal error carrying the panic value.

Source

Thrown at agent/sensors.go:167

		if !isValidSensor(sensorName, a.sensorConfig) {
			continue
		}
		// set dashboard temperature
		switch a.sensorConfig.primarySensor {
		case "":
			a.systemInfo.DashboardTemp = max(a.systemInfo.DashboardTemp, sensor.Temperature)
		case sensorName:
			a.systemInfo.DashboardTemp = sensor.Temperature
		}
		systemStats.Temperatures[sensorName] = utils.TwoDecimals(sensor.Temperature)
	}
}

// getTempsWithPanicRecovery wraps sensors.TemperaturesWithContext to recover from panics (gopsutil/issues/1832)
func (a *Agent) getTempsWithPanicRecovery(getTemps getTempsFn) (temps []sensors.TemperatureStat, err error) {
	defer func() {
		if r := recover(); r != nil {
			err = fmt.Errorf("panic: %v", r)
		}
	}()
	// get sensor data (error ignored intentionally as it may be only with one sensor)
	temps, _ = getTemps(a.sensorConfig.context)
	return
}

func (a *Agent) getTempsWithTimeout(getTemps getTempsFn) ([]sensors.TemperatureStat, error) {
	type result struct {
		temps []sensors.TemperatureStat
		err   error
	}

	// Use a longer timeout on the first run to allow for initialization
	// (e.g. Windows LHM subprocess startup)
	timeout := a.sensorConfig.timeout
	if a.sensorConfig.firstRun {
		a.sensorConfig.firstRun = false

View on GitHub (pinned to b38fb7dafa)

Solutions

  1. Upgrade gopsutil (and beszel agent) to a version past the panic fixed upstream (gopsutil/issues/1832).
  2. If only sensor temps fail, ignore — the agent continues and simply reports no temperature data.
  3. Check hwmon files under /sys/class/hwmon for malformed content and mask the offending module if needed.
  4. Pin to a known-good gopsutil version if you build beszel from source and the latest still panics.

Example fix

// before
require github.com/shirou/gopsutil/v3 v3.23.8 // panics in sensors
// after
require github.com/shirou/gopsutil/v3 v3.24.x // includes sensors panic fix
Defensive patterns

Strategy: try-catch

Try / catch

temps, err := a.getTempsWithPanicRecovery(sensors.TemperaturesWithContext)
if err != nil {
    slog.Warn("sensor read failed (recovered)", "err", err)
    temps = nil // continue without temperature data
}

Prevention

When it happens

Trigger: getTempsWithPanicRecovery calls getTemps(a.sensorConfig.context); the underlying gopsutil implementation panics (nil map/deref in sensor parsing on certain kernels/boards), the deferred recover() fires and err = fmt.Errorf("panic: %v", r).

Common situations: gopsutil version with the sensor-parsing bug on specific Linux hardware/DMI tables; unusual sysfs hwmon layouts (SBCs, some server boards); corrupted or oddly-formatted temperature sensor files.

Related errors


AI-assisted analysis of henrygd/beszel@b38fb7dafa (2026-08-31). Data as JSON: /api/errors/ee05b8315cf1ae5e. Report an issue: GitHub.