PMPARSEMETRICSPEC(3)
β¨ PMPARSEMETRICSPEC(3) β¨
okay bestie, so this one is pmParseMetricSpec and pmFreeMetricSpec from the Library Functions Manual β the uniform metric specification parser π
she's a libpcp girlie, part of the PCP (Performance Co-Pilot) situation, and honestly? she ate.
π NAME π
pmParseMetricSpec, pmFreeMetricSpec β uniform metric specification parser. yes that's the whole name section, no notes, periodt β¨
πΈ C SYNOPSIS πΈ
#include <pcp/pmapi.h>
int pmParseMetricSpec(const char *string, int isarch, char *source,
pmMetricSpec **rsltp, char **errmsg);
void pmFreeMetricSpec(pmMetricSpec *rslt);
cc ... -lpcp
like, you gotta link -lpcp or she simply will not show up. non-negotiable π«Ά
π DESCRIPTION π
so pmParseMetricSpec takes a string that names a PCP performance metric, and optionally the source for it β which is either a hostname or a PCP archive filename β plus the instances for that metric. the whole syntax vibe is described over in PCPIntro(1), go check her out π₯
if you don't provide either the host or the archive component in your metric spec, then the isarch and source arguments get used to fill in the returned pmMetricSpec structure instead. it's giving "we got you, bestie, we'll fill in the blanks" π
π¦ the struct π¦
the pmMetricSpec structure that comes back to you via rsltp represents the parsed string, and her declaration is literally this:
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;
look at her. isarch is doing main character work: 0 means live host, 1 means archive, 2 means local context. ninst being 0 means all the instances, and inst[1] is the array of instance names, iykyk π
π what she returns π
pmParseMetricSpec returns 0 if the given string was successfully parsed. slay. in that case, literally all the storage allocated by pmParseMetricSpec can be released with a single call to free(3) using the address returned from pmMetricSpec via rsltp. one call. that's it. the convenience macro pmFreeMetricSpec is, and I quote, a thinly disguised wrapper for free(3) β she's not doing anything fancy, she's just free(3) in a cute little outfit π
if the given string does not parse, pmParseMetricSpec returns PM_ERR_GENERIC and hands you a dynamically allocated error message string in errmsg. and bestie, you must free(3) that error message string in this situation. don't leave her hanging π
β οΈ undefined-behaviour check, and this is important so listen up: in the case of an error,rsltpis undefined. in the case of success,errmsgis undefined. and ifrsltp->ninstis0, thenrsltp->inst[0]is undefined. do not go poking at those, fr fr π
π SEE ALSO π
Performance Co-Pilot Β· PCP Β· PMPARSEMETRICSPEC(3) β that's the source, the version and the date, all wrapped up with a bow πβ¨ thanks for reading, mwah ππ¦πΈ
π¦ where this page comes from
- arch rolling: pcp 7.2.2-2 Β· GPL-2.0-or-later AND LGPL-2.1-or-later AND CC-BY-3.0
- centos-stream 10: pcp-doc 7.1.5-6.el10 Β· GPL-2.0-or-later AND CC-BY-3.0
- fedora 43: pcp-doc 7.0.1-1.fc43 Β· GPL-2.0-or-later AND CC-BY-3.0
- fedora 43: pcp-doc 7.2.1-1.fc43
- fedora 43: pcp-doc 7.2.2-1.fc43
- fedora 43: pcp-doc 7.2.2-2.fc43 Β· GPL-2.0-or-later AND CC-BY-3.0
- fedora 44: pcp-doc 7.1.0-6.fc44 Β· GPL-2.0-or-later AND CC-BY-3.0
- fedora 44: pcp-doc 7.2.1-1.fc44
- fedora 44: pcp-doc 7.2.2-1.fc44
- fedora 44: pcp-doc 7.2.2-2.fc44 Β· GPL-2.0-or-later AND CC-BY-3.0
- ubuntu resolute: libpcp4-dev 7.1.1-1
- ubuntu stonking: libpcp4-dev 7.2.1-2build1
- Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms