PMRECORD(3)
π PMRECORD(3) π
bestie. sit down. we're in the Library Functions Manual, section 3 (that's the C library functions girlies, yes ma'am), and we are about to learn how to make a recording session happen on the fly. no cap. β¨
π NAME π
pmRecordSetup, pmRecordAddHost, pmRecordControl β record mode support for PMAPI clients π
π C SYNOPSIS π
okay so first you gotta invite the header in:
#include <pcp/pmafm.h>
FILE *pmRecordSetup(const char *folio, const char *creator, int replay);
int pmRecordAddHost(const char *host, int isdefault,
pmRecordHost **rhp);
int pmRecordControl(pmRecordHost *rhp, int request,
const char *options);
and then you link against this, literally:
cc ... -lpcp_gui
β¨ DESCRIPTION β¨
These routines? They're the ones you use to create a Performance Co-Pilot (PCP) archive "on the fly", which is what makes "record mode" services possible for PMAPI client applications. iconic behavior fr fr π«Ά
Each record mode "session" involves one or more PCP archives, and every single one of those is created using a dedicated pmlogger(1) process. The whole thing gets an overall Archive Folio format β the kind pmafm(1) understands β so that all the archives belonging to one single recording session get named and collected together. πΈ
π¦ the pmRecordHost struct π¦
The pmRecordHost structure is what keeps state info flowing between the creator of the recording session and the associated pmlogger process(es). Here she is, defined, exactly as written:
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;
π how the routines team up π
The routines are used in combination to create a recording session, and it goes like this:
- Call
pmRecordSetupto establish a new recording session. A new Archive Folio will be created using the name folio; if the file or directory folio already exists, or the file folio cannot be created, this is an error. The application that is creating the session is identified by creator (most often this would be the same as the global PMAPI application name, as returned bypmGetProgname(3)). If the application knows how to create its own configuration file to replay the recorded session, then replay should be non-zero.
pmRecordSetup returns a stdio stream onto which the application should write the text of the required replay configuration file, if any.
- For each host that is to be included in the recording session, call
pmRecordAddHost. A newpmRecordHoststructure is returned via rhp. It is assumed thatpmcd(1)is running on host as this is howpmlogger(1)will retrieve the required performance metrics.
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. β οΈ one and only one, bestie, don't get greedy.
The calling application should write the desired pmlogger configuration onto the stdio stream returned via the f_config field in the pmRecordHost structure.
- Optionally add arguments to the command line that will be used to launch
pmlogger(1)by callingpmRecordControlwith a request ofPM_REC_SETARG. The argument is passed via options and one call topmRecordControlis required for each distinct argument.
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. π
automatic, no effort, slay.
- To commence the recording session, call
pmRecordControlwith a request ofPM_REC_ON, and rhp must beNULL. This will launch onepmlogger(1)process for each host in the recording session, and initialize thefd_ipc,logfile,pidandstatusfields in the associatedpmRecordHoststructure(s). - To terminate a
pmloggerinstance identified by rhp, callpmRecordControlwith a request ofPM_REC_OFF. If the rhp argument topmRecordControlisNULL, the termination request is broadcast to allpmloggerprocesses in the current recording session.
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.
- To display the current status of the
pmloggerinstance identified by rhp, callpmRecordControlwith a request ofPM_REC_STATUS. If the rhp argument topmRecordControlisNULL, the status request is broadcast to allpmloggerprocesses in the current recording session.
The display is generated directly by each pmlogger process and hence note the comments on the disposition of output from pmlogger below.
- To detach a
pmloggerinstance identified by rhp and allow it to continue independent of the application that launched the recording session, callpmRecordControlwith a request ofPM_REC_DETACH. If the rhp argument topmRecordControlisNULL, the detach request is broadcast to allpmloggerprocesses in the current recording session.
An informative dialog is generated directly by each pmlogger process and hence note the comments on the disposition of output from pmlogger below.
π«Ά do not close those streams, bestie. The calling application should not close any of the returned stdio streams; this will be done by pmRecordControl when recording is commenced. hands off, she's got it.
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. she's a main character, she handles it. π
π¬ about those dialogs π¬
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. β¨ aesthetic control, we love her.
π catching an early exit π
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.
π DIAGNOSTICS π
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. order matters, bestie, it's giving β¨sequenceβ¨.
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.
πΈ 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). π yes, mktemp(3), we said what we said.
XXXXXXβ If replay is non-zero, this is the creator's replay configuration file, else an empty control file, used to guarantee uniqueness.folioβ The PCP Archive Folio, suitable for use withpmafm(1).XXXXXX.host.configβ Thepmlogger(1)configuration for each host β if the same host is used in different calls topmRecordAddHostwithin the same recording session then one of the lettersathroughzwill be appended to theXXXXXXpart of all associated file names to ensure uniqueness. π€XXXXXX.host.logβstdoutandstderrfor thepmlogger(1)instance for each host.XXXXXX.host.{0,meta,index}β The files comprising a single PCP archive for each host.
π¦ SEE ALSO π¦
pmafm(1), pmlogger(1), pmquery(1) and PMAPI(3). go read those too, bestie, iykyk π
and that's the whole vibe check, babes π this page came to you from Performance Co-Pilot, that's PCP, and it's PMRECORD(3) β mwah, periodt. β¨ππ¦
π¦ 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: libpcp4-dev 7.1.1-1
- ubuntu stonking: libpcp4-dev 7.2.1-2build1
- Copyright (c) 1998-2008 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