|
NAME | C SYNOPSIS | DESCRIPTION | EXAMPLE | DIAGNOSTICS | SEE ALSO | COLOPHON |
|
|
|
PMISETVOLUMESIZE(3) Library Functions Manual PMISETVOLUMESIZE(3)
pmiSetVolumeSize - configure automatic data volume rotation for a
LOGIMPORT archive
#include <pcp/pmapi.h>
#include <pcp/import.h>
int pmiSetVolumeSize(size_t max_bytes, void (*on_rotate)(const
char *));
cc ... -lpcp_import -lpcp
As part of the Performance Co-Pilot Log Import API (see
LOGIMPORT(3)), pmiSetVolumeSize configures automatic data volume
rotation for the archive associated with the current context.
After each successful call to pmiHighResWrite(3) or pmiWrite(3),
if the current data volume file size meets or exceeds max_bytes,
the library closes the current data volume, opens the next num‐
bered volume, and writes a new volume label. Volume files are
named archive.0, archive.1, and so on, where archive is the base
path given to pmiStart(3). The .meta and .index files are shared
across all volumes and remain open throughout.
If on_rotate is not NULL, it is called immediately after the old
volume is closed and before the function returns. The single ar‐
gument is the full path of the just-closed volume file (e.g.
myarchive.0). The caller may use this callback to compress the
completed volume or perform any other post-rotation work. The
callback is invoked synchronously; long-running operations should
be deferred to a child process.
Passing max_bytes as zero disables volume rotation (the default).
pmiSetVolumeSize interacts with the existing PCP_LOGIM‐
PORT_MAXLOGSZ environment variable: both mechanisms trigger
newvolume() independently, so if both are active the smaller
threshold governs.
The following fragment opens a PCP archive, configures 100 MB vol‐
ume rotation, and compresses each completed volume:
static void
on_vol(const char *path)
{
char cmd[MAXPATHLEN + 32];
pmsprintf(cmd, sizeof(cmd), "xz %s &", path);
system(cmd);
}
pmiStart("myarchive", 0);
pmiSetVolumeSize(100 * 1024 * 1024, on_vol);
pmiSetVolumeSize returns zero on success. If there is no current
context, PM_ERR_NOCONTEXT is returned. If max_bytes is greater
than zero but does not exceed the on-disk label size for the con‐
figured archive version (124 bytes for v2, 800 bytes for v3),
PM_ERR_CONV is returned. A threshold at or below the label size
would cause the new volume's label to immediately exceed the
threshold on every write, triggering a rotation cascade.
LOGIMPORT(3), pmiEnd(3), pmiErrStr(3), pmiHighResWrite(3),
pmiStart(3), pmiWrite(3) and pmlogcheck(1).
This page is part of the PCP (Performance Co-Pilot) project. In‐
formation about the project can be found at ⟨http://www.pcp.io/⟩.
If you have a bug report for this manual page, send it to
pcp@groups.io. This page was obtained from the project's upstream
Git repository ⟨https://github.com/performancecopilot/pcp.git⟩ on
2026-08-04. (At that time, the date of the most recent commit
that was found in the repository was 2026-08-04.) 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 to man-pages@man7.org
Performance Co-Pilot PMISETVOLUMESIZE(3)