PMDAINSTANCE(3)
π PMDAINSTANCE π
okay bestie, welcome to pmdaInstance(3) β it lives in the Library Functions Manual section of the PCP docs, and it's literally the function that hands you back instance descriptions for a PMDA. sit down, hydrate, let's go π«Ά
β¨ NAME β¨
pmdaInstance β return instance descriptions for a PMDA
πΈ C SYNOPSIS πΈ
#include <pcp/pmapi.h>
#include <pcp/pmda.h>
int pmdaInstance(pmInDom indom, int inst, char *name,
pmInResult **result, pmdaExt *pmda);
cc ... -lpcp_pmda -lpcp
π¦ DESCRIPTION π¦
so pmdaInstance uses the standard PMDA(3) data structures to hand you info about the instance domain indom. no cap.
The result structure is built by pmdaInstance itself, and it'll contain one or more instance names and/or identifiers, depending on what you passed in inst and name. it's giving "choose your own adventure" but for instance domains π
Here's the vibe breakdown:
- If
insthas the valuePM_IN_NULLandnameis a null string, thenresultwill contain all the instance names and identifiers in the instance domain. the whole buffet. β¨ - If
instisPM_IN_NULLbutnameis the name of an instance in the instance domainindom, thenresultwill contain the instance identifier for instancename.
β οΈ note bestie: ifnamecontains no spaces, partial matching up to the first space in the instance name is performed β i.e."1"will match instance name"1 minute". But ifnamecontains an embedded space, then no partial matching happens andnameshould match one of the instance names exactly. exact match only, no vibes-based guessing.
- If
nameis a null string butinstis an instance identifier in the instance domainindom, thenresultwill contain the name for instanceinst. π₯
The result structure is allocated with malloc(3) and should be released by the caller with free(3). yes you have to clean up after yourself, the function is not your mom π
π MULTI-DIMENSIONAL INSTANCE NAMING π
further to the above description of name, the set of rules describing external instance names is provided in the pmdaCacheStore(3) manual page. go read it, it's the lore.
Instance domains add another dimension (a set of values) to metrics. But sometimes that's just not enough to describe complex multi-dimensional instance domain situations. for those girlies, the approach a bunch of PMDAs use is to structure the external instance names using a delimiter ("/" or "::" are most commonly used) so you can separate out the other dimensions. When that happens, instance domain labels should be used to define names for each instance name component. This lets PMAPI(3) client tools identify and refine value fetches to specific dimensions of interest. iconic behavior, honestly π
For example, some of the Linux kernel cgroup (control group) metric instance domains are multi-dimensional. The instance domain represents individual values across both control groups and CPUs, which makes it a two-dimensional instance domain. The instance names associated with this cgroup metrics indom have been structured using the "::" delimiter to separate the two dimensions. And the instance domain itself has been labeled accordingly, like this:
$ pminfo --desc --fetch --labels cgroup.cpuacct.usage_percpu
cgroup.cpuacct.usage_percpu
Data Type: 64-bit unsigned int InDom: 3.22 0xc00016
Semantics: counter Units: nanosec
inst [0 or "/::cpu0"] value 713787
inst [1 or "/::cpu1"] value 353969
inst [2 or "/app::cpu0"] value 407816
inst [3 or "/app::cpu1"] value 202747
inst [0 or "/::cpu0"] labels {"device_type":"cpu","cgroup":"/","cpu":0}
inst [1 or "/::cpu1"] labels {"device_type":"cpu","cgroup":"/","cpu":1}
inst [2 or "/app::cpu0"] labels {"device_type":"cpu","cgroup":"/app","cpu":0}
inst [3 or "/app::cpu1"] labels {"device_type":"cpu","cgroup":"/app","cpu":1}
$ pminfo --labels 3.22
InDom: 3.22 0xc00016
labels {"device_type":"cpu"}
As shown above, the individual instances inherit the labels from the instance domain, and the PMDA also applies additional per-instance labels describing individual cgroup and CPU names. When this model has been used by the PMDA, PMAPI clients are able to restrict their queries to the cgroup metric instances β in the example, restricting to processor "cpu0" using the "cpu" label, perhaps, or to just the "/app" cgroup metrics using the "cgroup" label. pick your filter, live your truth π
Furthermore, using this labeling scheme, client tools can also correlate related instances across different instance domains. cross-domain slay.
$ pminfo --desc --fetch --labels kernel.percpu.cpu.irq.soft
kernel.percpu.cpu.irq.soft
Data Type: 64-bit unsigned int InDom: 60.0 0xf000000
Semantics: counter Units: millisec
inst [0 or "cpu0"] value 6770
inst [1 or "cpu1"] value 100
inst [0 or "cpu0"] labels {"device_type":"cpu"}
inst [1 or "cpu1"] labels {"device_type":"cpu"}
$ pminfo --labels 60.0
InDom: 60.0 0xf000000
labels {"device_type":"cpu"}
Although these two metrics have different instance domains (60.0 and 3.22 respectively) and are sourced from different PMDAs, the "device_type" label identifies the common device to which these values relate. the way that a label can just connect two whole metrics... obsessed π
π CAVEAT π
The PMDA must be usingPMDA_INTERFACE_2or later, as specified in the call topmdaDSO(3)orpmdaDaemon(3). If labeling of multi-dimensional instance names is performed, the PMDA must usePMDA_INTERFACE_7or later.
Because of optional partial matching up to the first space in the instance name, the PMDA developer should ensure that if instance names are allowed to have spaces, the names are unique up to the first space. fr fr, don't skip this one π
π₯ DIAGNOSTICS π₯
If any errors occur during the execution of pmdaInstance, the result structure is deallocated. (it cleans up after itself in that case, at least π
)
- If the instance domain
indomis not supported by the PMDA,pmdaInstancewill returnPM_ERR_INDOM. - If the
instornamedoes not correspond to any instances in theindomdomain,pmdaInstancewill returnPM_ERR_INST.
π SEE ALSO π
malloc(3), PMAPI(3), PMDA(3), pmdaCacheStore(3), pmdaLabel(3) and pmGetInDom(3).
and that's the whole page bestie, you ate it up β go forth and query your instance domains responsibly πΈ
Performance Co-Pilot Β· PCP Β· PMDAINSTANCE(3) π π¦ π
π¦ 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: libpcp-pmda3-dev 7.1.1-1
- ubuntu stonking: libpcp-pmda3-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