File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -115,6 +115,28 @@ var labelGenerators = map[string]func(map[string]map[string]int) map[string]stri
115115 }
116116 return results
117117 },
118+ "product-name" : func (gpus map [string ]map [string ]int ) map [string ]string {
119+ counts := map [string ]int {}
120+ replacer := strings .NewReplacer (" " , "_" )
121+
122+ for _ , v := range gpus {
123+ prodnamePath := fmt .Sprintf ("/sys/class/drm/card%d/device/product_name" , v ["card" ])
124+ b , err := ioutil .ReadFile (prodnamePath )
125+ if err != nil {
126+ log .Error (err , prodnamePath )
127+ continue
128+ }
129+ prodName := strings .TrimSpace (string (b ))
130+ counts [prodName ]++
131+ }
132+
133+ pfx := createLabelPrefix ("product-name" , true )
134+ results := make (map [string ]string , len (counts ))
135+ for k , v := range counts {
136+ results [fmt .Sprintf ("%s.%s" , pfx , replacer .Replace (k ))] = strconv .Itoa (v )
137+ }
138+ return results
139+ },
118140 "vram" : func (gpus map [string ]map [string ]int ) map [string ]string {
119141 const bytePerMB = int64 (1024 * 1024 )
120142 counts := map [string ]int {}
You can’t perform that action at this time.
0 commit comments