NAME
kstat_create
,
kstat_install
, kstat_remove
,
kstat_destroy
—
kernel statistics provider
API
SYNOPSIS
#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);
DESCRIPTION
Kernel subsystems can export statistics to userland using the kernel statistics (kstat) API.
The
kstat_create
()
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
KSTAT_T_RAW
- The kstat provides raw bytes.
KSTAT_T_KV
- 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,
kstat_install
()
notifies the kstat subsystem that ks can be used to
export information to userland.
kstat_remove
()
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
().
kstat_destroy
()
removes ks from the list of exported statistics and
frees it.
CONTEXT
kstat_create
(),
kstat_install
(),
kstat_remove
(), and
kstat_destroy
() can be called during autoconf, or
from process context.
RETURN VALUES
kstat_create
() returns a pointer to a
kstat structure on success, or
NULL
on failure.
SEE ALSO
HISTORY
These functions first appeared in OpenBSD 6.8.
AUTHORS
David Gwynne <dlg@openbsd.org>