feat: GPU table display + fan speed collection

This commit is contained in:
ngfchl
2026-06-19 17:58:10 +08:00
parent 742928a93d
commit 7204f637ac
2 changed files with 61 additions and 46 deletions
+3 -1
View File
@@ -142,6 +142,7 @@ type GPUInfo struct {
CoreClock float64 `json:"core_clock_mhz"`
MemClock float64 `json:"mem_clock_mhz"`
Power float64 `json:"power_watts"`
FanSpeed float64 `json:"fan_speed"`
}
// ═══════════════════════════════════════════════
@@ -1085,7 +1086,7 @@ func tryNvidiaSMI() []GPUInfo {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
out, err := exec.CommandContext(ctx, "nvidia-smi",
"--query-gpu=index,name,memory.total,memory.used,memory.free,temperature.gpu,utilization.gpu,clocks.current.graphics,clocks.current.memory,power.draw",
"--query-gpu=index,name,memory.total,memory.used,memory.free,temperature.gpu,utilization.gpu,clocks.current.graphics,clocks.current.memory,power.draw,fan.speed",
"--format=csv,noheader,nounits",
).Output()
if err != nil {
@@ -1109,6 +1110,7 @@ func tryNvidiaSMI() []GPUInfo {
CoreClock: parseFloat(parts[7]),
MemClock: parseFloat(parts[8]),
Power: parseFloat(parts[9]),
FanSpeed: parseFloat(parts[10]),
})
}
return gpus