обработка командной строки для инструментов PMAPI (command line handling for PMAPI tools)
Значения флагов (Flags values)
PM_OPTFLAG_INIT
Used internally within the library to indicate
initialisation has been done, so that on subsequent calls
it will not be done again.
PM_OPTFLAG_DONE
Used primarily internally within the library to indicate
that the final option processing has been completed. This
processing involves cross-referencing a number of the
options, to check for mutual exclusion, for example.
There may be other post-processing at this stage also,
provided it does not require a PMAPI context.
PM_OPTFLAG_MULTI
Allow more than one host or set of archives to be
specified. The default is to allow one source of metrics
only, however some of the more sophisticated tools permit
multiple metric sources, each of which is handled within a
separate context. See also PM_OPTFLAG_MIXED
.
PM_OPTFLAG_USAGE_ERR
Indicates that the library has detected a command-line
usage error. This is an error such as when an option
requires an argument but none is supplied, or conflicting
options are specified (such as -s
and -T
).
PM_OPTFLAG_RUNTIME_ERR
Indicates that the library has detected an error at run
time. This is an error such as failing to retrieve
timezone information from pmcd(1) or failing to load an
alternate metric namespace from a local file (via the -n
option).
PM_OPTFLAG_EXIT
Indicates a suggestion from the library that the tool exit
cleanly. This is used when the version number is
requested, for example (the -V
option and PMOPT_VERSION
macro).
PM_OPTFLAG_POSIX
Use strict POSIX command line argument handling. This
means options and following arguments will not be
reordered, so additional options cannot follow command
line arguments. This may be important for tools where the
arguments can be negative numbers, for example, as these
should not be treated as command line options in this
case.
PM_OPTFLAG_MIXED
Allow both live and archive metric sources to be
specified. The default is to allow one type of metric
context only, however some of the more sophisticated tools
permit multiple context types. See also PM_OPTFLAG_MULTI
.
PM_OPTFLAG_ENV_ONLY
Many options can be specified through the either the
command line or from similarly-named environment
variables. This flag disables all argument parsing, and
only changes opts based on the environment variables.
This may be useful for tools wishing to ensure no command
line option conflicts occur between their own set and the
standard PCP option set (such as an existing tool,
reimplemented using PMAPI services).
PM_OPTFLAG_LONG_ONLY
Only process long options, not short options.
PM_OPTFLAG_BOUNDARIES
The default pmGetOptions
behaviour is to parse the time
window options (namely, -A
, -O
, -S
and -T
), only if one of
those options has been specified on the command line.
However, this flag can be used (particularly with archive
contexts) to find the start and finish times associated
with the context(s) even if no time window options were
specified. In the case of multiple archives, the time
window is defined as the time window spanning all of the
archives.
PM_OPTFLAG_STDOUT_TZ
The timezone being used will be reported on the standard
output stream during option parsing. The default
behaviour is to not report, but simply return timezone
information via the timezone (-Z
) and tzflag (-z
) fields
in the opts structure.
PM_OPTFLAG_NOFLUSH
The final pmflush
call issued by pmUsageMessage
will be
skipped if this flag is set. This is useful in situations
where the caller wishes to append additional test to the
generated usage message before flushing.
PM_OPTFLAG_QUIET
Suppress messages from pmgetopt_r
about unrecognised
command line options. This is the equivalent to setting
the opterr field in the opt parameter (which mimics the
getopt
variable of the same name).