PMIUNITS(3)

πŸ“¦ version 7.2.2, in arch rolling, fedora 43, fedora 44

✨ pmiUnits, pmiExtraUnits, pmiID, pmiInDom ✨

okay bestie, welcome to PMIUNITS(3) from the Library Functions Manual πŸ’– this is the page where we build the little data structures that hold metric identity and units, and honestly? it's giving "glue code but make it iconic" 🫢


🌸 NAME 🌸

pmiUnits, pmiExtraUnits, pmiID, pmiInDom β€” construct core metric data structures πŸ’…


πŸŽ€ C SYNOPSIS πŸŽ€

no cap, this is the C side of things, and you're gonna want these headers:

#include <pcp/pmapi.h>
#include <pcp/import.h>

pmID pmiID(int domain, int cluster, int item);
pmInDom pmiInDom(int domain, int serial);
pmUnits pmiUnits(int dimSpace, int dimTime, int dimCount,
                 unsigned int scaleSpace, unsigned int scaleTime,
                 unsigned int scaleCount);
pmUnits pmiExtraUnits(int dimSpace, int dimTime, int dimCount,
                      unsigned int scaleSpace, unsigned int scaleTime,
                      unsigned int scaleCount, int extraUnit,
                      unsigned int extraScale);

and when you link it, literally do this:

cc ... -lpcp_import -lpcp

πŸ¦‹ Perl SYNOPSIS πŸ¦‹

yes queen, there's a Perl binding, she's cute:

use PCP::LogImport;

$pmid = pmiID($domain, $cluster, $item);
$indom = pmiInDom($domain, $serial);
$units = pmiUnits($dimSpace, $dimTime, $dimCount, $scaleSpace,
                  $scaleTime, $scaleCount);
$units = pmiExtraUnits($dimSpace, $dimTime, $dimCount, $scaleSpace,
                       $scaleTime, $scaleCount, $extraUnit,
                       $extraScale);

🐍 Python SYNOPSIS 🐍

and Python said "not me being left out" πŸ™ˆ so here she is:

from pcp import pmi

pmid = pmi.pmiLogImport.pmiID(domain, cluster, item)
indom = pmi.pmiLogImport.pmiInDom(domain, serial)
units = pmi.pmiLogImport.pmiUnits(dim_space, dim_time, dim_count,
                          scale_space, scale_time, scale_count)

πŸ‘‘ DESCRIPTION πŸ‘‘

so. this whole crew lives inside the Performance Co-Pilot Log Import API (go read LOGIMPORT(3) bestie, it's the lore 🌈). these routines are your convenience methods β€” and lowkey that "especially for script use" energy is real, they were made for scripting β€” for constructing pmID, pmInDom and pmUnits structures respectively. then you take those and feed them into subsequent calls to pmiAddMetric(3) and pmiAddInstance(3). that's the whole pipeline, periodt ✨

now for the units part, and listen: if you want the complete description of what the components of a pmUnits structure actually mean β€” the values, the semantics, all of it β€” go read pmLookupDesc(3). and because that page defines what those components mean, it also defines the valid argument values for pmiUnits and pmiExtraUnits. so like, if you're guessing at dims and scales without reading it? don't. 🫢


🌟 SEE ALSO 🌟


and that's the page, bestie πŸ’œ this one's brought to you by Performance Co-Pilot a.k.a. PCP, and yes it's still filed under PMIUNITS(3) β€” now go forth and construct your structures, you've got this πŸ‘‘βœ¨πŸ’…

πŸ“¦ where this page comes from