PMDAGETOPTIONS(3)
π PMDAGETOPTIONS(3) β Library Functions Manual π
okay bestie, so this is a page from the Performance Co-Pilot library functions manual, and it's literally all about pmdaGetOpt and pmdaGetOptions, the two little icons that go grab options off your argument list and handle all the generic PMDA stuff for you β¨
β¨ NAME β¨
pmdaGetOpt, pmdaGetOptions β get options from arguments, parsing generic PMDA options π
πΈ C SYNOPSIS πΈ
#include <pcp/pmapi.h>
#include <pcp/pmda.h>
int pmdaGetOptions(int argc, char *const *argv, pmdaOptions *opts,
pmdaInterface *dispatch);
int pmdaGetOpt(int argc, char *const *argv, const char *optstring,
pmdaInterface *dispatch, int *err);
cc ... -lpcp_pmda -lpcp
π¦ DESCRIPTION π¦
so these two are basically wrappers for pmgetopt_r(3), no cap. the whole vibe is that certain options are assumed to have a predefined behavior, and that behavior initializes a bunch of fields in the pmdaInterface structure for you. main character energy fr fr π
pmdaGetOptionsβ the β¨fancyβ¨ one: it lets you have both short and long options.pmdaGetOptβ the lowkey one: short form options only.
π the options that BOTH of them will trap π
okay these are the ones both pmdaGetOptions and pmdaGetOpt snatch up:
-Ddebugspecβ sets thePMAPI(3)debugging options to debugspec, exactly as described inPCPIntro(1). it's giving "controlling levels of trace output while debugging" π-ddomainβ sets the domain number of this agent.-hhelpfileβ grabs the help text (peeppmdaText(3)) for the metrics from this file instead of from the path you specified withpmdaDSO(3)orpmdaDaemon(3).-iportβ expects PMCD to connect on inet port (number or name).-6portβ expects PMCD to connect on ipv6 port (number or name).-llogfileβ redirects diagnostics and trace output to logfile.-pβ expects PMCD to supply stdin/stdout pipe.-usocketβ expects PMCD to connect on unix domain socket.
π and the extra one that ONLY pmdaGetOptions captures π
pmdaGetOptions will also capture this one, and store it inside the opts parameter:
-Uusernameβ sets the user account name under which the PMDA should execute.
bestie, listen: only one of-i,-6,-pand-umay be specified. if none of these three options is given, a pipe (-p) is assumed. yes, the manpage says "these three" while listing four β iconic behavior, we don't question it π
when these options are encountered by pmdaGetOpt, the option gets processed and the next option is examined. so pmdaGetOpt will only return when an option that is not one of the ones listed above is found, or when the end of the list is reached. the returned value will be the argument, or EOF, respectively. π«Ά
a PMDA can control which of these options the program will accept with either the opts or the optstring argument:
- to accept all the options, call
pmdaGetOptionswith theshort_optionsfield of the opts structure set to thePMDA_OPTIONSmacro, - or call
pmdaGetOptwith the option string"D:d:h:i:l:pu:".
any PMDA specific options should be added to these strings in the style of getopt(3), and they'll be returned by both pmdaGetOptions and pmdaGetOpt if encountered. slay π
when a command line option usage error is detected in the pmdaGetOptions interface, the error field of the opts structure will contain a non-zero error count.
pmdaGetOpt takes a pointer to an int, err, which is used as an error count. this variable should be initialized to zero before pmdaGetOpt is first called, and tested when pmdaGetOpt returns EOF.
neitherpmdaGetOptionsnorpmdaGetOptmodify their argc or argv parameters. they would NEVER. hands off π
the global variables used by the system getopt(3) interface may also be used by the caller of pmdaGetOpt within the argument parsing loop. π
on the other hand, the pmdaGetOptions interface does not utilize global variables at all β neither reading nor modifying them. instead, these variables can be access via the opts fields of the same name. iykyk β¨
π CAVEAT π
the options -D, -d, -i, -l, -p and -u cannot be reused for other purposes by the PMDA, unless using the override method provided by the pmdaGetOptions interface, which operates in the same way as described for the pmGetOptions(3) interface used by PMAPI client tools. so don't try it bestie, that's a no π
the PMDA must be using PMDA_INTERFACE_2 or later, as specified in the call to pmdaDSO(3) or pmdaDaemon(3). periodt.
π₯ DIAGNOSTICS π₯
both pmdaGetOptions and pmdaGetOpt will display the same error messages as getopt. matching energy, honestly π
β SEE ALSO β
pmdbg(1), getopt(3), pmgetopt_r(3), pmGetOptions(3), PMAPI(3), PMDA(3), pmdaDaemon(3), pmdaDSO(3) and pmdaText(3).
and that's the whole page, bestie π¦β¨ this one came from Performance Co-Pilot (PCP) β it's the PMDAGETOPTIONS(3) page π go forth and parse your options, you absolute legend π
π¦ 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) 2014 Red Hat
- 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