@cryptotaxi247 / netdata-1 / commits / c22ad52f9

feat(go.d/nvidia_smi): add "index" label to GPU charts (#18833)

Ilya Mashchenko committed Oct 21, 2024 at 13:14 UTC c22ad52f96bc69ddd6a27ae0460b4cac8f601d33
3 files changed +9 -6
src/go/plugin/go.d/modules/nvidia_smi/charts.go
+3 -2
@@ -4,6 +4,7 @@ package nvidia_smi
4
5 import (
6 "fmt"
7 + "strconv"
8 "strings"
9
10 "github.com/netdata/netdata/go/plugins/plugin/go.d/agent/module"
@@ -261,7 +262,7 @@ var (
262 }
263 )
264
264 -func (nv *NvidiaSmi) addGPUXMLCharts(gpu gpuInfo) {
265 +func (nv *NvidiaSmi) addGpuCharts(gpu gpuInfo, index int) {
266 charts := gpuXMLCharts.Copy()
267
268 if !isValidValue(gpu.Utilization.GpuUtil) {
@@ -294,7 +295,7 @@ func (nv *NvidiaSmi) addGPUXMLCharts(gpu gpuInfo) {
295 for _, c := range *charts {
296 c.ID = fmt.Sprintf(c.ID, strings.ToLower(gpu.UUID))
297 c.Labels = []module.Label{
297 - // csv output has no 'product_brand'
298 + {Key: "index", Value: strconv.Itoa(index)},
299 {Key: "uuid", Value: gpu.UUID},
300 {Key: "product_name", Value: gpu.ProductName},
301 }
src/go/plugin/go.d/modules/nvidia_smi/collect.go
+2 -2
@@ -38,7 +38,7 @@ func (nv *NvidiaSmi) collectGPUInfo(mx map[string]int64) error {
38 seenGPU := make(map[string]bool)
39 seenMIG := make(map[string]bool)
40
41 - for _, gpu := range info.GPUs {
41 + for i, gpu := range info.GPUs {
42 if !isValidValue(gpu.UUID) {
43 continue
44 }
@@ -49,7 +49,7 @@ func (nv *NvidiaSmi) collectGPUInfo(mx map[string]int64) error {
49
50 if !nv.gpus[px] {
51 nv.gpus[px] = true
52 - nv.addGPUXMLCharts(gpu)
52 + nv.addGpuCharts(gpu, i)
53 }
54
55 addMetric(mx, px+"pcie_bandwidth_usage_rx", gpu.PCI.RxUtil, 1024) // KB => bytes
src/go/plugin/go.d/modules/nvidia_smi/metadata.yaml
+4 -2
@@ -98,7 +98,9 @@ modules:
98 description: These metrics refer to the GPU.
99 labels:
100 - name: uuid
101 - description: GPU id (e.g. 00000000:00:04.0)
101 + description: GPU uuid (e.g. GPU-27b94a00-ed54-5c24-b1fd-1054085de32a)
102 + - name: index
103 + description: GPU index (nvidia_smi typically orders GPUs by PCI bus ID)
104 - name: product_name
105 description: GPU product name (e.g. NVIDIA A100-SXM4-40GB)
106 metrics:
@@ -211,7 +213,7 @@ modules:
213 description: These metrics refer to the Multi-Instance GPU (MIG).
214 labels:
215 - name: uuid
214 - description: GPU id (e.g. 00000000:00:04.0)
216 + description: GPU uuid (e.g. GPU-27b94a00-ed54-5c24-b1fd-1054085de32a)
217 - name: product_name
218 description: GPU product name (e.g. NVIDIA A100-SXM4-40GB)
219 - name: gpu_instance_id