OpenBSD manual page server

Manual Page Search Parameters

KSTAT_CREATE(9) Kernel Developer's Manual KSTAT_CREATE(9)

kstat_create, kstat_install, kstat_remove, kstat_destroykernel statistics provider API

#include <sys/kstat.h>

struct kstat *
kstat_create(const char *provider, unsigned int instance, const char *name, unsigned int unit, unsigned int type, unsigned int flags);

void
kstat_install(struct kstat *ks);

void
kstat_remove(struct kstat *ks);

void
kstat_destroy(struct kstat *ks);

Kernel subsystems can export statistics to userland using the kernel statistics (kstat) API.

The () function allocates a kstat structure and adds it to the list of statistics that userland can query. A kstat is uniquely identified by a tuple made up of the provider, instances, name, and unit arguments. The type of information provided by the kstat is identified by the type argument. The supported kstat types are

The kstat provides raw bytes.
The kstat provides a series of struct kstat_kv structures that represent key/value information. See kstat_kv_init(9) for more detail.

Once a kstat structure has been created, the caller is responsible for initialising the structure.

After the structure has been initialised, () notifies the kstat subsystem that ks can be used to export information to userland.

() disables the kstat, preventing it from being used to export information to userland. This allows allocations referenced by the kstat struct to be released and configuration torn down before the kstat itself is freed with kstat_destroy().

() removes ks from the list of exported statistics and frees it.

kstat_create(), kstat_install(), kstat_remove(), and kstat_destroy() can be called during autoconf, or from process context.

kstat_create() returns a pointer to a kstat structure on success, or NULL on failure.

kstat_kv_init(9)

These functions first appeared in OpenBSD 6.8.

David Gwynne <dlg@openbsd.org>

January 31, 2022 OpenBSD-7.1