Top: the second of two identical GPUs draws its busy graph

Its sensors were gpu.<name>.usage_2 and so on; the page looks under gpu.<name>_2. Each
card now gets its own stem, as the page already assumed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Mitchell-Johnson
2026-11-10 00:40:56 -08:00
co-authored by Claude Opus 5.5
parent f1c66ce886
commit 0e57419d8b
+6
View File
@@ -142,8 +142,14 @@ func flatten(s Sample, want func(id string) bool) []sensors.Sensor {
f.add(p+".used_pct", x.Mount+" used", "usage", "%", ratio(x.Used, x.Size), s.fsT, pct, lbl...) f.add(p+".used_pct", x.Mount+" used", "usage", "%", ratio(x.Used, x.Size), s.fsT, pct, lbl...)
} }
gpuSeen := map[string]int{}
for _, g := range s.GPUs { for _, g := range s.GPUs {
// two identical cards are gpu.<name> and gpu.<name>_2, every sensor of the second under
// its own stem (not add's suffix on the end of each id, which the page can't find)
p := "gpu." + sensors.Seg(g.Name) p := "gpu." + sensors.Seg(g.Name)
if gpuSeen[p]++; gpuSeen[p] > 1 {
p = fmt.Sprintf("%s_%d", p, gpuSeen[p])
}
lbl := []string{"name", g.Name, "driver", g.Driver} lbl := []string{"name", g.Name, "driver", g.Driver}
if g.Bus != "" { if g.Bus != "" {
lbl = append(lbl, "bus", g.Bus) lbl = append(lbl, "bus", g.Bus)