PMIDSTR(3)

πŸ“¦
version 7.2.2 Β· 3 versions
, in arch rolling, centos-stream 10, fedora 43, fedora 44, ubuntu resolute, ubuntu stonking

πŸ’– PMIDSTR(3) πŸ’–

okay bestie, so this is a page from the Library Functions Manual for PCP, and it's literally about turning a performance metric identifier into something your eyeballs can actually read. slay.


✨ NAME ✨

pmIDStr, pmIDStr_r β€” convert a performance metric identifier into a string πŸŽ€


✨ C SYNOPSIS ✨

#include <pcp/pmapi.h>

const char *pmIDStr(pmID pmid);
char *pmIDStr_r(pmID pmid, char *buf, int buflen);

cc ... -lpcp

✨ DESCRIPTION ✨

So the vibe here is: you're writing error messages and diagnostic stuff, right, and you need a version of the specified Performance Metric Identifier (PMID) that a human can look at without crying. That's pmIDStr β€” it hands you back a "human readable" version. 🫢

pmIDStr_r does literally the same thing, except it stashes the result in a buffer you supply, called buf, of length buflen. And that buffer should have room for at least 20 bytes, no cap. πŸ™ˆ

Here's the tea about what's going on under the hood: internally a PMID is encoded with three fields β€” domain, cluster and item. pmIDStr gives you back a string with each of those fields showing up as decimal numbers, separated by periods. iconic. πŸ’…

⚠️ and now the important part: the string value that comes back from pmIDStr lives in a single static buffer. so the returned value is only valid until the next call to pmIDStr. it's giving "use it or lose it" energy, fr fr.


✨ NOTES ✨

pmIDStr returns a pointer to a static buffer and hence is not thread-safe. πŸ’€

Multi-threaded applications should use pmIDStr_r instead. periodt.

✨ PCP ENVIRONMENT ✨

Environment variables with the prefix PCP_ are used to parameterize the file and directory names used by PCP. 🌈

On each installation, the file /etc/pcp.conf contains the local values for these variables. The $PCP_CONF variable may be used to specify an alternative configuration file, as described in pcp.conf(5). And you can grab values for these variables programmatically using the pmGetConfig(3) function. πŸ’–


✨ SEE ALSO ✨

PMAPI(3), pmGetConfig(3), pmInDomStr(3), pmTypeStr(3), pmSemStr(3), pmUnitsStr(3), pmLookupDesc(3), pcp.conf(5) and pcp.env(5). πŸ‘‘


and that's the whole page bestie, go forth and stringify responsibly πŸ¦‹πŸ’œ

Performance Co-Pilot made this one, and it's tagged PCP, dated with the rest of the PMIDSTR(3) crew β€” mwah, love that for them. πŸŽ€βœ¨

πŸ“¦ where this page comes from