diff --git a/internal/pkg/envcheck/capabilities.go b/internal/pkg/envcheck/capabilities.go index abe06d2..7d4d55b 100644 --- a/internal/pkg/envcheck/capabilities.go +++ b/internal/pkg/envcheck/capabilities.go @@ -1,4 +1,4 @@ -// Copyright 2026 MarketAlly. All rights reserved. +// Copyright 2026 MarketAlly. All rights reserved. // SPDX-License-Identifier: MIT package envcheck @@ -967,23 +967,19 @@ func detectCPULoad() *CPUInfo { } } case "windows": - // Windows doesn't have load average, use CPU usage via wmic - ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + // Windows doesn't have load average, use PowerShell to get CPU usage + // wmic is deprecated, use Get-CimInstance instead + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() - cmd := exec.CommandContext(ctx, "wmic", "cpu", "get", "loadpercentage") + cmd := exec.CommandContext(ctx, "powershell", "-NoProfile", "-Command", + "(Get-CimInstance Win32_Processor | Measure-Object -Property LoadPercentage -Average).Average") output, err := cmd.Output() if err == nil { - lines := strings.Split(string(output), "\n") - for _, line := range lines { - line = strings.TrimSpace(line) - if line != "" && line != "LoadPercentage" { - if load, err := parseFloat(line); err == nil { - // Convert percentage to "load" equivalent - info.LoadPercent = load - info.LoadAvg1m = load * float64(numCPU) / 100.0 - return info - } - } + line := strings.TrimSpace(string(output)) + if load, err := parseFloat(line); err == nil { + info.LoadPercent = load + info.LoadAvg1m = load * float64(numCPU) / 100.0 + return info } } }