pmRecordAddHost (3) - Linux Manuals
pmRecordAddHost: record mode support for PMAPI clients
NAME
pmafm, pmRecordSetup, pmRecordAddHost, pmRecordControl - record mode support for PMAPI clientsC SYNOPSIS
#include <pcp/pmafm.h>
Each record mode ``session'' involves one or more
PCP archive logs each created using a dedicated
pmlogger(1)
process, with an overall Archive Folio format as understood by
pmafm(1),
to name and collect all of the archive logs associated with
a single recording session.
The
pmRecordHost
structure is used to maintain state information between the
creator of the recording session and the associated
pmlogger
process(es). The structure is defined as:
The routines are used in combination to create a recording session
as follows.
pmRecordSetup
returns a
stdio
stream onto
which the application should write the text of the required
replay configuration file, if any.
If this
host
is the default host for this recording session, then
isdefault
should be non-zero. This will ensure that the corresponding archive
appears first in the PCP archive folio, and hence the tools used
to replay the archive folio will make the correct determination of the
archive associated with the default host.
At most one
host
per recording session may be nominated as the default host.
The calling application should
write the desired
pmlogger
configuration onto the
stdio
stream returned via the
f_config
field in the
pmRecordHost
structure.
An argument may be added for a particular
pmlogger
instance
identified by
rhp,
or if the
rhp
argument
is NULL the argument is added for all
pmlogger
instances that will be launched in the current recording session.
Independent of any calls to
pmRecordControl
with a
request
of
PM_REC_SETARG,
each
pmlogger
instance will automatically be launched with the following arguments:
-c,
-h,
-l,
-x
and the basename for the PCP archive log.
An informative dialog is generated directly by each
pmlogger
process and hence note the comments on the disposition of output from
pmlogger
below.
Alternatively,
pmlogger
can be started with options to limit the duration of logging, e.g. the
-T
or
-s
arguments, in which case there is no need to call
pmRecordControl
with a
request
of
PM_REC_OFF
and no dialog is generated.
The display is generated directly by each
pmlogger
process and hence note the comments on the disposition of output from
pmlogger
below.
An informative dialog is generated directly by each
pmlogger
process and hence note the comments on the disposition of output from
pmlogger
below.
The calling application should not close any of the returned
stdio
streams; this will be done by
pmRecordControl
when recording is commenced.
Once
pmlogger
has been started for a recording session, then
pmlogger
will assume responsibility for any dialog with the user in the event
that the application that launched the recording session should
exit, particularly without terminating the recording session.
By default, information and dialogs from
pmlogger
will be displayed using
pmquery(1)
on the assumption that most applications wishing to launch
a recording session are GUI-based. In the event that
pmquery
fails to display the information (for example, because the
DISPLAY
environment variable is not set),
pmlogger
will write on its own
stderr
stream (not
the
stderr
stream of the launching process);
the output will be assigned to the
XXXXXX.host.log
file described in the FILES section below.
For convenience, the full pathname to this file is provided via the
logfile
field in the
pmRecordHost
structure.
If the
options
argument to
pmRecordControl
is not NULL, this string may be
used to pass additional arguments to
pmquery(1)
in those cases where a dialog is to be displayed. One use of this
capability would be to
provide a
-geometry
string to control the placement of the dialog.
Premature termination of a launched
pmlogger
process may be determined using the
pmRecordHost
structure,
by calling
select(2)
on the
fd_ipc
field
or polling the
status
field that will contain the termination status from
waitpid(2)
if known, else -1.
pmRecordSetup
may return
NULL
in the event of an error.
Check
errno
for the real cause, but the value
EINVAL
typically means that the order of calls to these routines is
not correct (there is obvious state associated with the current
recording session that is maintained across calls to these routines).
For example
the following calls would produce this
EINVAL
error;
calling
pmRecordControl
before calling
pmRecordAddHost
at least once, or calling
pmRecordAddHost
before calling
pmRecordSetup.
pmRecordControl
and
pmRecordAddHost
both return 0 on success, else a value less than 0 suitable for
decoding with
pmErrStr(3)
on failure.
The value
-EINVAL
has the same interpretation as
errno
being set to
EINVAL
as described above.
pmRecordControl
will return
PM_ERR_IPC
if the associated
pmlogger
process has already exited.
FILE *pmRecordSetup(const char *folio, const char *creator, int
int pmRecordAddHost(const char *host, int isdefault, pmRecordHost
int pmRecordControl(pmRecordHost *rhp, int request, const char DESCRIPTION
These routines may be used to create a Performance Co-Pilot (PCP)
archive ``on the fly'' to
support ``record mode'' services for PMAPI client applications.
typedef struct {
FILE *f_config; /* caller writes pmlogger configuration here */
int fd_ipc; /* IPC channel to pmlogger */
char *logfile; /* full pathname for pmlogger error logfile */
pid_t pid; /* process id for pmlogger */
int status; /* exit status, -1 if unknown */
} pmRecordHost;
FILES
These routines create a number of files in the
same directory
as the
folio
file named in the call to
pmRecordSetup.
In all cases, the ``XXXXXX'' component is the result of
calling
mktemp(3).
DIAGNOSTICS