From 383913505fa7da5f5b0bdcbb3534ce55a5d73245 Mon Sep 17 00:00:00 2001 From: henrygd Date: Mon, 12 Jan 2026 16:12:36 -0500 Subject: [PATCH] agent: fix tegrastats VDD_SYS_GPU parsing - Parse VDD_SYS_GPU / correctly - Add regression test for GPU@ temp + VDD_SYS_GPU power --- agent/gpu.go | 8 +++++++- agent/gpu_test.go | 13 +++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/agent/gpu.go b/agent/gpu.go index 81cb83db..80e8bae4 100644 --- a/agent/gpu.go +++ b/agent/gpu.go @@ -168,7 +168,13 @@ func (gm *GPUManager) getJetsonParser() func(output []byte) bool { // Parse power usage powerMatches := powerPattern.FindSubmatch(output) if powerMatches != nil { - power, _ := strconv.ParseFloat(string(powerMatches[2]), 64) + // powerMatches[2] is the "(GPU_SOC|CPU_GPU_CV) mW" capture + // powerMatches[3] is the "VDD_SYS_GPU /" capture + powerStr := string(powerMatches[2]) + if powerStr == "" { + powerStr = string(powerMatches[3]) + } + power, _ := strconv.ParseFloat(powerStr, 64) gpuData.Power += power / milliwattsInAWatt } gpuData.Count++ diff --git a/agent/gpu_test.go b/agent/gpu_test.go index ddfa2367..65520fb2 100644 --- a/agent/gpu_test.go +++ b/agent/gpu_test.go @@ -307,6 +307,19 @@ func TestParseJetsonData(t *testing.T) { Count: 1, }, }, + { + name: "orin-style output with GPU@ temp and VDD_SYS_GPU power", + input: "RAM 3276/7859MB (lfb 5x4MB) SWAP 1626/12122MB (cached 181MB) CPU [44%@1421,49%@2031,67%@2034,17%@1420,25%@1419,8%@1420] EMC_FREQ 1%@1866 GR3D_FREQ 0%@114 APE 150 MTS fg 1% bg 1% PLL@42.5C MCPU@42.5C PMIC@50C Tboard@38C GPU@39.5C BCPU@42.5C thermal@41.3C Tdiode@39.25C VDD_SYS_GPU 182/182 VDD_SYS_SOC 730/730 VDD_4V0_WIFI 0/0 VDD_IN 5297/5297 VDD_SYS_CPU 1917/1917 VDD_SYS_DDR 1241/1241", + wantMetrics: &system.GPUData{ + Name: "GPU", + MemoryUsed: 3276.0, + MemoryTotal: 7859.0, + Usage: 0.0, + Power: 0.182, // 182mW -> 0.182W + Temperature: 39.5, + Count: 1, + }, + }, } for _, tt := range tests {