Product SiteDocumentation Site

3.9.2. Initializing New Metrics

Using the code generated by pmgenmap, you are now able to easily initialize the application's metric specifications as shown in Example 3.20, “Initializing Metric Specifications”:

Example 3.20. Initializing Metric Specifications

/* C code fragment from pmclient.c */
numpmid = sizeof(pmclient_sample) / sizeof(char *);
if ((pmidlist = (pmID *)malloc(numpmid * sizeof(pmidlist[0]))) == NULL) {...}
if ((sts = pmLookupName(numpmid, pmclient_sample, pmidlist)) < 0) {...}
# The equivalent python code would be
pmclient_sample = ("kernel.all.load", "kernel.percpu.cpu.user",
	"kernel.percpu.cpu.sys", "mem.freemem", "disk.all.total")
pmidlist = context.pmLookupName(pmclient_sample)
At this stage, pmidlist contains the PMID for the five metrics of interest.