These functions are wrappers for pmgetopt_r(3). The behavior of each
function is that certain options are assumed to have a predefined
behavior which initializes several fields in the pmdaInterface
structure. The pmdaGetOptions interface allows both short and long
options to be given, whereas pmdaGetOpt allows for short form options
The options that both pmdaGetOptions and pmdaGetOpt will trap are:
-Dtrace Set the PMAPI(3) debug control variable (pmDebug) to
trace. Used for controlling levels of trace output
-ddomain Set the domain number of this agent.
-hhelpfile Obtain the help text (see pmdaText(3)) for the metrics
from this file rather than from the path specified
with pmdaDSO(3) or pmdaDaemon(3).
-iport Expect PMCD to connect on inet port (number or name).
-6port Expect PMCD to connect on ipv6 port (number or name).
-llogfile Redirect diagnostics and trace output to logfile.
-p Expect PMCD to supply stdin/stdout pipe.
-usocket Expect PMCD to connect on unix domain socket.
The pmdaGetOptions interface will also capture the following options,
and store them within the opts parameter:
-Uusername Set the user account name under which the PMDA should
Only one of -i, -6, -p and -u may be specified. If none of these
three options is given, a pipe (-p) is assumed. When these options
are encountered by pmdaGetOpt, the option is processed and the next
option is examined. Therefore, pmdaGetOpt will only return when an
option other than those listed above is found, or the end of the list
is reached. The returned value will be the argument or EOF,
A PMDA can control which of these options the program will accept
with either the opts or optstring argument. To accept all the
options, the PMDA should call pmdaGetOptions with the short_options
field of the opts structure set to the PMDA_OPTIONS macro, or
pmdaGetOpt with 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 will be returned by both pmdaGetOptions and pmdaGetOpt if
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.
Neither pmdaGetOptions nor pmdaGetOpt modify their argc or argv
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
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
The PMDA must be using PMDA_INTERFACE_2 or later, as specified in the
call to pmdaDSO(3) or pmdaDaemon(3).
This page is part of the PCP (Performance Co-Pilot) project.
Information about the project can be found at ⟨http://www.pcp.io/⟩.
If you have a bug report for this manual page, send it to
email@example.com. This page was obtained from the project's upstream
Git repository ⟨git://git.pcp.io/pcp⟩ on 2017-03-13. If you discover
any rendering problems in this HTML version of the page, or you
believe there is a better or more up-to-date source for the page, or
you have corrections or improvements to the information in this
COLOPHON (which is not part of the original manual page), send a mail
Performance Co-Pilot PCP PMDAGETOPTIONS(3)