PMISETIMPORTPROGRAM(3)
π PMISETIMPORTPROGRAM π
okay bestie, welcome to the Performance Co-Pilot library functions manual, and today's main character is pmiSetImportProgram β the lil function that goes "hey pmdapmimport, notice me π" and registers your import tool so the whole world (well, the pmimport.* metric family) can see what it's up to. β¨
πΈ NAME πΈ
pmiSetImportProgram β register an import tool with pmdapmimport
π C SYNOPSIS π
#include <pcp/pmapi.h>
#include <pcp/import.h>
int pmiSetImportProgram(const char *tool, const char *version, const char *args, const char *archive);
cc ... -lpcp_import -lpcp
π¦ DESCRIPTION π¦
So here's the tea β β this function is part of the Performance Co-Pilot Log Import API (peep LOGIMPORT(3) if you wanna get caught up). What pmiSetImportProgram does is register the import tool that's currently running with pmdapmimport(1), so that its status is visible through the pmimport.* metric family. it's giving "main character announces themselves." π
The function writes a sidecar status file to PCP_IMPORTRUN_DIR (typically /run/pmimport), and the file is named after tool. It's a simple key=value text format, and it can contain a subset of these fields:
pid=β the process ID of the import tool. This one gets written only when thePMI_PROCESSflag was passed topmiStart(3). Long-running daemons should totally use this flag, because thenpmdapmimport(1)can detect and suppress stale entries left behind by an unclean exit π. One-shot tools (like, say, the ones a cron job invokes periodically) should omit the flag β their sidecar files persist between invocations and are always considered live. no flag, no problem.version=β the version string supplied by the caller. (Skipped ifNULLor empty. bye.)args=β theargsstring supplied by the caller. (Also skipped ifNULLor empty.) Typically this is a summary of the subsystems or data sources being imported, sopcp(1)can display it. slay.archive=β the archive base path supplied by the caller. (Yep, skipped ifNULLor empty too.)
The sidecar file gets removed automatically when pmiEnd(3) is called, so you don't need to do any explicit cleanup on a clean exit. self-cleaning, iconic behavior π§
Timing matters, bestie: pmiSetImportProgram should be called once after pmiStart(3) and before the first call to pmiWrite(3). And calling it again with updated arguments (say, after an archive rotation) is totally permitted β it just overwrites the existing sidecar file. glow-up via overwrite β¨
π DIAGNOSTICS π
- Returns zero on success. periodt.
PM_ERR_NOCONTEXTβ returned if there is no current import context. πPM_ERR_CONVβ returned iftoolisNULLor empty.- Any error opening or writing the sidecar file causes the corresponding negated
errno(3)value to be returned.
heads up: that negated errno thing is real β don't go comparing it against plain errno values or you'll be confused and we don't want that for you π«Ά
π FILES π
$PCP_IMPORTRUN_DIR/<tool>β sidecar status file for the named import tool.
β SEE ALSO β
LOGIMPORT(3), pcp(1), pmdapmimport(1), pmiEnd(3), pmiErrStr(3), pmiStart(3), pmiWrite(3) and pmiWriteNow(3).
and that's the whole vibe check, bestie π this page came to you courtesy of Performance Co-Pilot β PMISETIMPORTPROGRAM(3), go forth and register your import tools with confidence. no cap. ππΈπ¦
π¦ 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
- 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.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 stonking: libpcp4-dev 7.2.1-2build1
- Copyright (c) 2026 Red Hat
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms