PMDALABEL(3)
π PMDALABEL(3) π
okay bestie, gather round, because this is a page from the Library Functions Manual and it's literally about filling up pmLabelSet structures with metric labels. yes, labels. the little name-tag stickers of the PCP world. π
β¨ NAME β¨
pmdaLabel, pmdaSetLabelCallBack β fill pmLabelSet structures with metric labels π·οΈβ¨
πΈ C SYNOPSIS πΈ
#include <pcp/pmapi.h>
#include <pcp/pmda.h>
int pmdaLabel(int ident, int type, pmLabelSet **sets, pmdaExt *pmda);
int pmdaSetLabelCallBack(pmdaInterface *dispatch,
pmdaLabelCallBack callback);
cc ... -lpcp_pmda -lpcp
do not forget the link flags bestie, -lpcp_pmda AND -lpcp, both of them, we are not doing half the job π
π¦ DESCRIPTION π¦
so. part of the Performance Metrics Domain Agent (PMDA) API β that's the PMDA(3) thing, go read it β and pmdaLabel uses the standard PMDA(3) data structures to hand you back the labels for a performance domain, an instance domain, a metric, or individual instances, all in "JSONB" format, tucked into the sets data structure you passed in. no cap. π
the type argument is the main character here: it decides how to read ident AND what kind of label you're asking for. so, like:
PM_LABEL_DOMAINβ whenidentis a PMDA domain identifier πPM_LABEL_CLUSTERβ whenidentis a metric identifier and you're requesting labels for the cluster containing that metric ποΈPM_LABEL_ITEMβ whenidentis a metric identifier βPM_LABEL_INDOMβ whenidentis an instance domain identifier πPM_LABEL_INSTANCESβ whenidentis a metric identifier and you want labels for all the instances of that metric π«Ά
β οΈ the label sets pointer must be initialised toNULLbefore you callpmdaLabel, and space is only to be allocated when labels are actually present and returned. when that happens, the return code must indicate the number of label sets that got allocated. and heads up: this will only ever be greater than one in thePM_LABEL_INSTANCEScase. one. literally just the one. except there. π
now, the tea β β this is one of the few generic callbacks in libpcp_pmda (again: PMDA(3)) that is incomplete, meaning it needs a further pmdaLabelCallBack method of its own to actually work. you register that extra callback with pmdaSetLabelCallBack, and the pmdaLabelCallBack method has this prototype:
int func(pmInDom indom, unsigned int inst, pmLabelSet **set)
the whole purpose of the pmdaLabelCallBack routine is to return the label(s) for an individual instance inst of a given instance domain, indom. and its successful return code is significantly different from pmdaLabel's β like, do not mix these up β as described below π
π CAVEAT π
your PMDA has to be using PMDA_INTERFACE_7 or later, as specified in the call to pmdaDSO(3) or pmdaDaemon(3). older interface? it's giving not today. π
π₯ DIAGNOSTICS π₯
on success, pmdaLabel returns the number of label sets created. usually that's zero or one β except in the PM_LABEL_INSTANCES case, where more than one label set will often come back, one for each instance of the requested metric. so many little name tags. so many. πππ
by contrast β and this is the plot twist β on success of the pmdaLabelCallBack routine you must return the number of labels successfully added to the provided labelset pointer, and not the total number of label sets. different number. different meaning. periodt. π
and if the labels for the requested entity could not be obtained because of a catastrophic failure β like an out of memory condition, that kind of nightmare β these routines will return a negative error code. π
π SEE ALSO π
pminfo(1), malloc(3), PMAPI(3), PMDA(3), pmdaDaemon(3), pmdaDSO(3), pmdaInit(3) and pmLookupLabels(3). go read them, iykyk π«Ά
and that's the whole page bestie!! this one came to you courtesy of Performance Co-Pilot, PCP, dated PMDALABEL(3) β slay, ate, no crumbs, go label some metrics πβ¨π¦
π¦ 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) 2016-2017 Red Hat. All Rights Reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms