PMTRAVERSEPMNS(3)
β¨ NAME β¨
so this is PMTRAVERSEPMNS(3), straight out of the Library Functions Manual, and it's here to teach you how to traverse the performance metrics name space π¦
pmTraversePMNS,pmTraversePMNS_rβ traverse the performance metrics name space
like. that's the whole job. walking the PMNS. and bestie, it does it so well π
πΈ C SYNOPSIS πΈ
#include <pcp/pmapi.h>
int pmTraversePMNS(const char *name, void (*dometric)(const char *));
int pmTraversePMNS_r(const char *name,
void (*dometric_r)(const char *, void *),
void *closure);
cc ... -lpcp
yeah you're gonna need to link -lpcp, don't forget it, i'm serious π
π DESCRIPTION π
okay so the routine pmTraversePMNS may be used to perform a depth-first traversal of the Performance Metrics Name Space (the PMNS, you know her π).
The traversal starts at the node identified by name β and if name is an empty string (i.e. ""), the traversal starts at the root of the PMNS, iconic behaviour honestly. Usually name would be the pathname of a non-leaf node in the PMNS, iykyk.
For each leaf node (i.e. performance metric) found in the traversal, your user-supplied routine dometric is called with the full pathname of that metric in the PMNS as the single argument. That argument is null-byte terminated, and it's constructed from a buffer that is managed internally to pmTraversePMNS. which means β
π¨ the value is only valid during the call todometric. if you need to keep that pathname, copy it withstrdup(3)before returning fromdometric. no holding onto it, bestie, it will evaporate on you π
The pmTraversePMNS_r routine performs the same function, except the callback method func_r has an additional parameter that will be closure from the initial call to pmTraversePMNS_r. The additional parameter to pmTraversePMNS_r and the callback method allows the caller to pass context through pmTraversePMNS_r and into the callback method func_r, making the service way more useful for multi-threaded applications, where thread-private data can be accessed in the callback method via the closure argument. that's the whole point of the _r version and she ate π₯
On success, pmTraversePMNS and pmTraversePMNS_r return the number of leaf nodes found in the traversal, which will be one (1) if name is either a leaf node, or a derived metric, or a non-leaf node with one child. If name is a non-leaf node, the returned value will be zero or greater β and yes, zero is returned in the special case where name is a dynamic root node that currently has no children (a sad, empty little node, but valid π₯Ί). In all cases, derived metrics present in the PMNS subtree below name are counted as leaf-nodes.
If an error occurs, pmTraversePMNS and pmTraversePMNS_r will return a negative error code, as described in the DIAGNOSTICS section below. keep scrolling β¬οΈ
π DIAGNOSTICS π
PM_ERR_NOPMNS
Failed to access a PMNS for operation. π’ and this part is important: note that if the application hasn't a priori called pmLoadNameSpace(3) and wants to use the distributed PMNS, then a call to pmTraversePMNS must be made inside a current context. no context, no traversal, that's the vibe check.
PM_ERR_NAME
The initial pathname name is not valid in the current PMNS. π
PM_ERR_*
Other diagnostics are for protocol failures when accessing the distributed PMNS. so like, network drama, not your fault π«Ά
π SEE ALSO π
and that's the page, bestie!! π«Ά this was Performance Co-Pilot, PCP, PMTRAVERSEPMNS(3) β thanks for reading all the way to the footer, you're literally the main character πβ¨π
π¦ 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