KVM_GETCPTIME(3)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1

🌸 NAME 🌸

kvm_getcptime β€” fetch global CPU time statistics πŸ’–

okay so this is the manual page for KVM_GETCPTIME(3) from the Library Functions Manual, and it's literally all about grabbing the global CPU time stats. slay.

πŸ“š LIBRARY πŸ“š

Kernel Data Access Library (libkvm, -lkvm) 🫢

✨ SYNOPSIS ✨

bestie, you're gonna need these includes and then the function call:

#include <sys/param.h>
#include <sys/resource.h>
#include <sys/sysctl.h>
#include <kvm.h>

int
kvm_getcptime(kvm_t *kd, long *cp_time);

πŸ’… DESCRIPTION πŸ’…

The kvm_getcptime() function stores the global CPU time statistics from the kernel kd into the array of counters that cp_time points to. πŸŽ€

tiny but important note: cp_time should point to an array of CPUSTATES long integers. no cap.

The format of those counters is identical to the output from the kern.cp_time sysctl. iconic.

🧚 CACHING 🧚

This function caches the nlist values for various kernel variables and reuses them in successive calls. lowkey efficient. ✨

You may call the function with kd set to NULL to clear this cache. yep, that's the reset-button vibe.

🌈 RETURN VALUES 🌈

The kvm_getcptime function returns 0 on success and -1 on failure. periodt.

If an error occurs, then an error message may be retrieved via kvm_geterr(3). so if things go sideways, that's where you look πŸ‘€.

πŸ¦‹ SEE ALSO πŸ¦‹


cute little sign-off: this page is from Debian, dated August 19, 2008, and it's the KVM_GETCPTIME(3) manual page πŸ’œ byeee!

πŸ“¦ where this page comes from