pmwebtimerregister(3) — Linux manual page

NAME | C SYNOPSIS | DESCRIPTION | RETURN VALUE | DIAGNOSTICS | SEE ALSO | COLOPHON

PMWEBTIMERREGISTER(3)   Library Functions Manual   PMWEBTIMERREGISTER(3)

NAME         top

       pmWebTimerRegister, pmWebTimerRelease,
       pmWebTimerSetMetricRegistry - thread-safe timer list management

C SYNOPSIS         top

       #include <pcp/pmwebapi.h>

       typedef void (*pmWebTimerCallBack)(void *data);
       int pmWebTimerRegister(pmWebTimerCallBack callback, void *data);

       int pmWebTimerRelease(int seq);
       int pmWebTimerSetMetricRegistry(struct mmv_registry *registry);
       cc ... -lpcp_web

DESCRIPTION         top

       The pmWebTimerRegister and related API functions provide a conve‐
       nient  thread-safe API for applications to manage a list of timer
       driven callbacks.  On the first  call  to  pmWebTimerRegister  or
       pmWebTimerSetMetricRegistry, an internal timer is set up and ini‐
       tialized  to  fire every 1.0 seconds.  Each time the timer fires,
       all currently registered callback functions will be called  seri‐
       ally  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 exe‐
       cute quickly and synchronously.  Typical callback  functions  in‐
       clude  refreshing  instrumentation, calculating and updating per‐
       formance metric values, 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 pointer to an libpcp_mmv(3)
       registry that has been suitably initialized by the calling appli‐
       cation.  This registry 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 applica‐
       tion.  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).

RETURN VALUE         top

       The pmWebTimerRegister function returns a positive integer handle
       that may be subsequently used in a call to  pmWebTimerRelease  to
       remove a timer from the internal timer list.  When a timer is re‐
       moved  with a call to pmWebTimerRelease, the internal data struc‐
       tures are freed.  The caller however, is responsible for  freeing
       the associated data (since it may or may not be dynamically allo‐
       cated).

DIAGNOSTICS         top

       On failure a negative PMAPI error code is returned in all cases.

SEE ALSO         top

       pmproxy(1), mmv_stats_registry(3), PMAPI(3) and PMWEBAPI(3).

COLOPHON         top

       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   2024-06-14.
       (At  that time, the date of the most recent commit that was found
       in the repository was 2024-06-14.)  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               PCP             PMWEBTIMERREGISTER(3)