From 52b8264e4e1d38605463112c30da42c067be7dcd Mon Sep 17 00:00:00 2001 From: "Christopher J. Morrone" Date: Fri, 19 Jan 2024 16:40:03 -0800 Subject: [PATCH] dcgm_sampler: fix handling of DCGM string fields Use correct ldms function to add string metrics. Add error messages. Fixes #1321 --- ldms/src/sampler/dcgm_sampler/dcgm_sampler.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/ldms/src/sampler/dcgm_sampler/dcgm_sampler.c b/ldms/src/sampler/dcgm_sampler/dcgm_sampler.c index f51a04741..f603852b3 100644 --- a/ldms/src/sampler/dcgm_sampler/dcgm_sampler.c +++ b/ldms/src/sampler/dcgm_sampler/dcgm_sampler.c @@ -318,9 +318,24 @@ static int gpu_schema_create() field_meta = DcgmFieldGetById(conf.fields[i]); ldms_type = dcgm_to_ldms_type(field_meta->fieldType); - rc = ldms_schema_metric_add(sch, field_meta->tag, ldms_type); - if (rc < 0) + if (ldms_type == LDMS_V_NONE) { + ovis_log(mylog, OVIS_LERROR, + "DCGM field %d has a DCGM type %d, which is not supported by this sampler\n", + conf.fields[i], field_meta->fieldType); + goto err2; + } + if (ldms_type == LDMS_V_CHAR_ARRAY) { + rc = ldms_schema_metric_array_add(sch, field_meta->tag, + ldms_type, field_meta->valueFormat->width+1); + } else { + rc = ldms_schema_metric_add(sch, field_meta->tag, ldms_type); + } + if (rc < 0) { + ovis_log(mylog, OVIS_LERROR, + "failed adding ldms metric to set for DCGM field %d, DCGM type %d\n", + conf.fields[i], field_meta->fieldType); goto err2; + } translation_table[conf.fields[i]].ldms_index = rc; translation_table[conf.fields[i]].ldms_type = ldms_type; }