PMPARSEMETRICSPEC(3) Library Functions ManualPMPARSEMETRICSPEC(3)pmParseMetricSpec,pmFreeMetricSpec- uniform metric specification parser
#include <pcp/pmapi.h>int pmParseMetricSpec(const char *string, intisarch,char *source, pmMetricSpec **rsltp,char **errmsg);void pmFreeMetricSpec(pmMetricSpec *rslt);cc ... -lpcp
pmParseMetricSpecaccepts astringspecifying the name of a PCP performance metric, and optionally the source (either a hostname or a PCP archive filename) and instances for that metric. The syntax is described inPCPIntro(1). If neitherhostnorarchivecomponent of the metric specification is provided, theisarchandsourcearguments are used to fill in the returnedpmMetricSpecstructure. ThepmMetricSpecstructure that is returned viarsltprepresents the parsedstringand has the following declaration: typedef struct { int isarch; /* source type: 0 -> live host, 1 -> archive, 2 -> local context */ char *source; /* name of source host or archive */ char *metric; /* name of metric */ int ninst; /* number of instances, 0 -> all */ char *inst[1]; /* array of instance names */ } pmMetricSpec;pmParseMetricSpecreturns 0 if the givenstringwas successfully parsed. In this case all the storage allocated bypmParseMetric‐Speccan be released by a single call tofree(3) using the address returned frompmMetricSpecviarsltp. The convenience macropm‐FreeMetricSpecis a thinly disguised wrapper forfree(3).pmParseMetricSpecreturnsPM_ERR_GENERICand a dynamically allo‐ cated error message string inerrmsg, if the givenstringdoes not parse. Be sure tofree(3) the error message string in this situa‐ tion. In the case of an error,rsltpis undefined. In the case of suc‐ cess,errmsgis undefined. Ifrsltp->ninstis 0, thenrsltp->in‐st[0]is undefined.PMAPI(3) andpmLookupName(3).
This page is part of thePCP (Performance Co-Pilot) project. In‐ formation about the project can be found at ⟨http://www.pcp.io/⟩. If you have a bug report for this manual page, send it to pcp@groups.io. This page was obtained from the project's upstream Git repository ⟨https://github.com/performancecopilot/pcp.git⟩ on 2025-08-11. (At that time, the date of the most recent commit that was found in the repository was 2025-08-11.) If you discover any rendering problems in this HTML version of the page, or you believe there is a better or more up-to-date source for the page, or you have corrections or improvements to the information in this COLOPHON (which isnot part of the original manual page), send a mail to man-pages@man7.orgPerformance Co-Pilot PCPPMPARSEMETRICSPEC(3)HTML rendering created 2025-09-06 byMichael Kerrisk, author ofThe Linux Programming Interface. For details of in-depthLinux/UNIX system programming training courses that I teach, lookhere. Hosting byjambit GmbH. | ![]() |