From c382c1d5f67635641741bb68a7a4a045c8c2c064 Mon Sep 17 00:00:00 2001 From: henrygd Date: Fri, 5 Sep 2025 10:39:18 -0400 Subject: [PATCH] windows: make LHM opt-in with LHM=true (#1130) --- beszel/internal/agent/sensors_windows.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/beszel/internal/agent/sensors_windows.go b/beszel/internal/agent/sensors_windows.go index 8ee2c9b..c4b2997 100644 --- a/beszel/internal/agent/sensors_windows.go +++ b/beszel/internal/agent/sensors_windows.go @@ -46,9 +46,10 @@ var lhmFs embed.FS var ( beszelLhm *lhmProcess beszelLhmOnce sync.Once + useLHM = os.Getenv("LHM") == "true" ) -var errNoSensors = errors.New("no sensors found (try running as admin)") +var errNoSensors = errors.New("no sensors found (try running as admin with LHM=true)") // newlhmProcess copies the embedded LHM executable to a temporary directory and starts it. func newlhmProcess() (*lhmProcess, error) { @@ -139,7 +140,7 @@ func (lhm *lhmProcess) cleanupProcess() { } func (lhm *lhmProcess) getTemps(ctx context.Context) (temps []sensors.TemperatureStat, err error) { - if lhm.stoppedNoSensors { + if !useLHM || lhm.stoppedNoSensors { // Fall back to gopsutil if we can't get sensors from LHM return sensors.TemperaturesWithContext(ctx) } @@ -222,6 +223,10 @@ func getSensorTemps(ctx context.Context) (temps []sensors.TemperatureStat, err e } }() + if !useLHM { + return sensors.TemperaturesWithContext(ctx) + } + // Initialize process once beszelLhmOnce.Do(func() { beszelLhm, err = newlhmProcess()