PMLOOKUPNAME(3)
π NAME π
pmLookupName β the girlies that translate performance metric names into PMIDs. that's it, that's the job π
β¨ C SYNOPSIS β¨
#include <pcp/pmapi.h>
int pmLookupName(int numpmid, const char **namelist, pmID *pmidlist);
cc ... -lpcp
π DESCRIPTION π
okay so bestie, here's the vibe. you hand over namelist, which is a list holding numpmid full pathnames for performance metrics from a Performance Metrics Name Space (PMNS). then pmLookupName hands you back the list of associated Performance Metric Identifiers (PMIDs) via pmidlist. giving matchmaker, giving wingwoman π¦
Now β and this is the part where you gotta pay attention, fr fr β what pmLookupName returns depends on the presence of any lookup failures, their severity and the number of metrics being looked up. three whole variables, main character energy:
- If there are no lookup failures, the return value will be
numpmid. clean. flawless. no notes β¨ - If a fatal error is encountered, the return value will be less than 0. For example
PM_ERR_TOOSMALL,PM_ERR_NOPMNSorPM_ERR_IPC. yeah that's a bad day π - If
numpmidis greater than one and non-fatal error(s) are encountered, the return value is the number of metric names that have successfully been looked up (greater than or equal to zero and less than or equal tonumpmid). partial slay, honestly. - If
numpmidis one and a non-fatal error is encountered, the return value is the error code (less than zero). single lookup = single error code, no ambiguity, we love a clear communicator π«Ά
When errors are encountered, any metrics that cannot be looked up result in the corresponding element of pmidlist being set to PM_ID_NULL. so like, the slot is still there, it's just β¨emptyβ¨ π
The slightly convoluted error protocol allows bulk lookups, then probing for more error details in the case of a specific failure, as shown in the EXAMPLES section below. it's giving detective work, and honestly? it works π₯
Note that the error protocol guarantees there is a 1:1 relationship between the elements ofnamelistandpmidlist, hence both lists contain exactlynumpmidelements. For this reason, the caller is expected to have preallocated a suitably sized array forpmidlist. so bestie, malloc before you call, i am literally begging π
π EXAMPLE π
#include <pcp/pmapi.h>
#define NUMPMID (sizeof(names)/sizeof(const char *))
const char *names[] = {
"sample.bin",
"sample",
"sample.bog",
"sample.secret.bar",
"sample.secret.bar.bad"
};
pmID pmids[NUMPMID];
int
main(int argc, char **argv)
{
int sts;
int numpmid = NUMPMID;
pmNewContext(PM_CONTEXT_HOST, "local:");
sts = pmLookupName(numpmid, names, pmids);
if (sts < 0) {
fprintf(stderr, "pmLookupName failed: %s0, pmErrStr(sts));
exit(1);
}
if (sts != numpmid) {
/*
* some of the lookups failed ... report the reason(s)
*/
int i;
for (i = 0; i < numpmid; i++) {
if (pmids[i] != PM_ID_NULL) continue;
/* this one failed */
sts = pmLookupName(1, &names[i], &pmids[i]);
fprintf(stderr, "%s: lookup failed: %s0, names[i], pmErrStr(sts));
}
exit(1);
}
/* all good ... */
...
}
see? bulk lookup first, then when something's off you go back in one at a time to get the actual reason. forensic girlie behavior πβ¨
π©· DIAGNOSTICS π©·
PM_ERR_TOOSMALLβnumpmidmust be at least 1. like, you can't look up zero names, that's not a thing, bestie πPM_ERR_NOPMNSβ Failed to access a PMNS for operation. Note that if the application hasn't a priori calledpmLoadNameSpace(3)and wants to use the distributed PMNS, then a call topmLookupNamemust be made after the creation of a context (seepmNewContext(3)). order of operations, babe πPM_ERR_NAMEβnamelist[0]does not correspond to a valid metric name in the PMNS. typo? in THIS economy? πPM_ERR_NONLEAFβnamelist[0]refers to a node in the PMNS but it was not a leaf node. you pointed at a whole branch, not a metric. iconic mistake, happens to everyone πΈPM_ERR_*β Other diagnostics are for protocol failures when accessing the distributed PMNS. yeah when the network starts acting up π
π SEE ALSO π
PMAPI(3), pmGetChildren(3), pmGetChildrenStatus(3), pmGetConfig(3), pmLoadNameSpace(3), pmNameID(3), pmNewContext(3), pcp.conf(5) and pcp.env(5).
go read them, they're all lowkey connected, iykyk π¦
and that's the whole page, bestie π this one lives in the Performance Co-Pilot world, brought to you by PCP β so if you ever need to cite it, that's the source/version energy right there. now go forth and look up them metrics, you absolute icon πβ¨π
π¦ 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 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