---
name: "pmWebTimerRegister"
section: "3"
platform: "linux"
package: "pcp"
version: "7.2.2-2"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/pmWebTimerRegister"
---

# pmWebTimerRegister(3)

thread-safe timer list management

## NAME

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

## C SYNOPSIS

**#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

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 **pmWebTimerSetMetricRegistry**, 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 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 application. 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)](/PMNS/5.md)** 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)](/getrusage/2.md), [**times**(2)](/times/2.md) and **[getpid(2)](/getpid/2.md).**

## RETURN VALUE

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 removed with a call to **pmWebTimerRelease**, the internal data structures are freed. The caller however, is responsible for freeing the associated **data** (since it may or may not be dynamically allocated).

## DIAGNOSTICS

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

## SEE ALSO

[**pmproxy**(1)](/pmproxy/1.md), [**mmv\_stats\_registry**(3)](/mmv_stats_registry/3.md), [**PMAPI**(3)](/PMAPI/3.md) and [**PMWEBAPI**(3)](/PMWEBAPI/3.md).
