PMDISCOVERSETUP(3)
okay bestie, we're reading PMDISCOVERSETUP(3) from the Library Functions Manual today and it's literally the girlboss of asynchronous archive discovery π β¨
β¨ NAME β¨
pmDiscoverSetup, pmDiscoverSetSlots, pmDiscoverSetEventLoop, pmDiscoverSetConfiguration, pmDiscoverSetMetricRegistry, pmDiscoverClose β asynchronous archive location and contents discovery services π¦
πΈ C SYNOPSIS πΈ
#include <pcp/pmwebapi.h>
int pmDiscoverSetup(pmDiscoverModule *module,
pmDiscoverCallBacks *callbacks, void *arg);
int pmDiscoverSetSlots(pmDiscoverModule *module, void *slots);
int pmDiscoverSetEventLoop(pmDiscoverModule *module, void *uvloop);
int pmDiscoverSetConfiguration(pmDiscoverModule *module,
struct dict *config);
int pmDiscoverSetMetricRegistry(pmDiscoverModule *module,
struct mmv_registry *registry);
int pmDiscoverClose(pmDiscoverModule *module);
cc ... -lpcp_web
π DESCRIPTION π
So pmDiscoverSetup and her little friend group are like, a whole integral part of the libpcp_web API library β the one that gets used by and described in pmwebapi(3), pmproxy(1), pmseries(1) and literally everywhere else. What they do? They give you an asynchronous, event driven mechanism to automatically discover PCP archives created by pmlogger(1) and by any other application that can write PCP archives. Yes, that includes pmrep(1) and any other app using the LOGIMPORT(3) API to import performance data into the PCP infrastructure and write PCP archives. iconic behavior tbh π
The pmDiscover API services dynamically discover, monitor and manage directories of PCP archives as they're created, written to, compressed, and eventually deleted. The underlying archive life-cycle is normally managed by the PCP archive management infrastructure (peep pmlogger_daily(1) for that). Discovered archives that are active (like, currently being written) get "log-tailed" to extract near live/real-time performance data, which then gets passed off via registered callbacks for further processing β e.g. adding the data to a key-value server. Archives that are compressed or inactive are tracked/monitored but not log-tailed β and no, that's not a vibe, that's a fact: compressed archives never grow, so log-tailing would never discover any new data. (See the --load option in pmseries(1) for a supported mechanism for ingesting previously collected (inctive) PCP archives, whether compressed or not, into a key-value server. iykyk π«Ά)
The pmDiscover routines can be configured to automatically discover and monitor PCP archives in one or more directories, as specified in the pmDiscoverModule, which is initially set up by calling pmDiscoverSetConfiguration to create a module of type pmDiscoverModule, as described above. The resulting module then gets passed to pmDiscoverSetup along with an initialized structure of callbacks of type pmDiscoverCallBacks. it's giving plumbing but make it cute π
Setting up a discovery module and callbacks would normally declare an instance of pmDiscoverSettings, like:
#include <pcp/pmwebapi.h>
static pmDiscoverSettings someapp_discover = {
.callbacks.on_source = pmSomeappDiscoverSource,
.callbacks.on_closed = pmSomeappDiscoverClosed,
.callbacks.on_labels = pmSomeappDiscoverLabels,
.callbacks.on_metric = pmSomeappDiscoverMetric,
.callbacks.on_values = pmSomeappDiscoverValues,
.callbacks.on_indom = pmSomeappDiscoverInDom,
.callbacks.on_text = pmSomeappDiscoverText,
.module.on_info = someapp_logging_function,
};
And then you initialize this with API calls similar to the following:
pmDiscoverSetEventLoop(&someapp_discover.module, myevents);
pmDiscoverSetConfiguration(&someapp_discover.module, myconfig);
pmDiscoverSetMetricRegistry(&someapp_discover.module, metric_registry);
pmDiscoverSetup(&someapp_discover.module, &someapp_discover.callbacks, &privatedata);
The above code must then implement each of the declared callbacks etc. to do whatever is required with the data passed in to the callback. Prototypes for these callbacks can be found in the pmwebapi.h header. The callbacks will be made asynchronously β as archives are discovered or deleted, and as new data is written to active archive volume and metadata files. main character energy, honestly π
In the case of pmproxy(1), callbacks are registered to capture performance data, which is then sent to a key-value server for fast scalable time-series queries by clients of the PMWEBAPI(3) REST API services. Such clients include the pmseries(1) application and pmproxy(1), which is the back-end REST API server for grafana-pcp, a native grafana-server(1) data-source for PCP. slay π
π©Ί DIAGNOSTICS π©Ί
Generally zero on success, or on error a negative return code β go see pmerr(1). no cap, if it's negative, something's up π
π FILES π
The default archive directory is $PCP_ARCHIVE_DIR, which is normally /var/log/pcp/pmlogger. The API recursively descends all sub-directories and also dynamically discovers any new directories or archives found therein. she's nosy and we love that for her π
π SEE ALSO π
grafana-server(1), pmerr(1), pmlogger(1), pmproxy(1), pmseries(1), PMWEBAPI(3), mmv_stats_registry(3), PMAPI(3), pmErrStr(3), pcp.conf(5) and pcp.env(5).
that's the whole page, bestie β brought to you by Performance Co-Pilot (that's the source, that's the version, it's just PCP π), same as always. go discover some archives fr fr β¨π¦πΈ
π¦ 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) 2019-2020 Red Hat
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms