The pmWebTimerRegister and related API functions provide a convenient thread-safe API for applications to
manage a list of timer driven callbacks. On the first call to pmWebTimerRegister or pmWebTimerSetMetri‐cRegistry, an internal timer is set up and initialized to fire every 1.0 seconds. Each time the timer
fires, all currently registered callback functions will be called serially with the opaque data pointer
that was supplied when each function was registered. The pmWebTimerCallBack typedef provides a suitable
callback function prototype.
All registered callback functions should be non-blocking and execute quickly and synchronously. Typical
callback functions include refreshing instrumentation, calculating and updating performance metric val‐
ues, periodic garbage collection and any other local function that requires regular execution.
The pmWebTimerSetMetricRegistry function provides a convenient way for an application to pass in a point‐
er to an libpcp_mmv(3) registry that has been suitably initialized by the calling application. This reg‐istry will be used to dynamically create six server resource metrics named NAME.mem.datasz,
NAME.mem.maxrss, NAME.cpu.total, NAME.cpu.sys, NAME.cpu.user and NAME.pid, where NAME is the root PCP
PMNS(5) name set up by the calling application. These metrics should be reasonably self explanatory;
they provide resource usage metrics from the calling application / server and use getrusage(2), times(2)
and getpid(2).