libstatgrab(3)
okay bestie, welcome to libstatgrab(3) β the manual page for statgrab, libstatgrab. The vibe is system statistics, but make it cross-platform π
.
β¨ NAME β¨
statgrab, libstatgrab - get system statistics
πΈ SYNOPSIS πΈ
here's the whole lineup, bestie β every single signature, no skipping:
#include <statgrab.h>
sg_error sg_init (int ignore_init_errors);
sg_error sg_shutdown (void);
sg_error sg_drop_privileges (void);
sg_error sg_get_error (void);
const char *sg_get_error_arg (void);
int sg_get_error_errno (void);
const char *sg_str_error (sg_error code);
sg_error sg_get_error_details (sg_error_details *err_details);
char *sg_strperror (char **buf, const sg_error_details * const
err_details);
size_t sg_get_nelements (const void *data);
sg_error sg_free_stats_buf (void *data);
sg_error sg_lock_mutex (const char *mutex_name);
sg_error sg_unlock_mutex (const char *mutex_name);
sg_cpu_percents *sg_get_cpu_percents (void);
sg_cpu_percents *sg_get_cpu_percents_of (sg_cpu_percent_source cps);
sg_cpu_percents *sg_get_cpu_percents_r (const sg_cpu_stats *whereof);
void sg_free_cpu_percents (sg_cpu_percents *data);
sg_cpu_stats *sg_get_cpu_stats (void);
sg_cpu_stats *sg_get_cpu_stats_diff (void);
sg_cpu_stats *sg_get_cpu_stats_r (void);
sg_cpu_stats *sg_get_cpu_stats_diff_between (const sg_cpu_stats
*cpu_now, const sg_cpu_stats *cpu_last);
sg_error sg_free_cpu_stats (sg_cpu_stats *data);
sg_disk_io_stats *sg_get_disk_io_stats (size_t *entries);
sg_disk_io_stats *sg_get_disk_io_stats_r (size_t *entries);
sg_disk_io_stats *sg_get_disk_io_stats_diff (size_t *entries);
sg_disk_io_stats *sg_get_disk_io_stats_diff_between (const
sg_disk_io_stats *cur, const sg_disk_io_stats *last,
size_t *entries);
sg_error sg_free_disk_io_stats (sg_disk_io_stats *data);
sg_fs_stats *sg_get_fs_stats (size_t *entries);
sg_fs_stats *sg_get_fs_stats_r (size_t *entries);
sg_error sg_free_fs_stats (sg_fs_stats *data);
const char **sg_get_valid_filesystems (size_t *entries);
sg_error sg_set_valid_filesystems (const char *valid_fs[]);
sg_host_info *sg_get_host_info (void);
sg_host_info *sg_get_host_info_r (void);
sg_error sg_free_host_info (sg_host_info *data);
sg_load_stats *sg_get_load_stats (void);
sg_load_stats *sg_get_load_stats (void);
sg_error sg_free_load_stats (sg_load_stats *data);
sg_mem_stats *sg_get_mem_stats (void);
sg_mem_stats *sg_get_mem_stats_r (void);
sg_error sg_free_mem_stats (sg_mem_stats *data);
sg_swap_stats *sg_get_swap_stats (void);
sg_swap_stats *sg_get_swap_stats_r (void);
sg_error sg_free_swap_stats (sg_swap_stats *data);
sg_network_iface_stats *sg_get_network_iface_stats (size_t *entries);
sg_network_iface_stats *sg_get_network_iface_stats_r (size_t *entries);
sg_error sg_free_network_iface_stats (sg_network_iface_stats *data);
sg_network_io_stats *sg_get_network_io_stats (size_t *entries);
sg_network_io_stats *sg_get_network_io_stats_r (size_t *entries);
sg_network_io_stats *sg_get_network_io_stats_diff (size_t *entries);
sg_network_io_stats *sg_get_network_io_stats_diff_between (const
sg_network_io_stats *cur, const sg_network_io_stats
*last, size_t *entries);
sg_error sg_free_network_io_stats (sg_network_iface_stats *data);
sg_page_stats *sg_get_page_stats (void);
sg_page_stats *sg_get_page_stats_r (void);
sg_page_stats *sg_get_page_stats_diff (void);
sg_page_stats *sg_get_page_stats_diff_between (const sg_page_stats *cur,
const sg_page_stats *last);
sg_error sg_free_page_stats (sg_page_stats *data);
sg_process_stats *sg_get_process_stats (size_t *entries);
sg_process_stats *sg_get_process_stats_r (size_t *entries);
sg_error sg_free_process_stats (sg_process_stats *data);
sg_process_count *sg_get_process_count (void);
sg_process_count *sg_get_process_count_of (sg_process_count_source pcs);
sg_process_count *sg_get_process_count_r (sg_process_stats const
*whereof);
sg_error sg_free_process_count (sg_process_count *data);
sg_user_stats *sg_get_user_stats (size_t *entries);
sg_user_stats *sg_get_user_stats_r (size_t *entries);
sg_error sg_free_user_stats (sg_user_stats *data);
π¦ DESCRIPTION π¦
okay so real talk: the statgrab library gives you a cross-platform interface to get several system statistics. System statistics are not standardised β rude, I know β so the statgrab library tries to choose the most important values over all supported operating systems. That means some values might not be available on every OS, while some specific values are missing when there are no counterparts on any other OS. No cap π.
libstatgrab is organised in components, each one for interrelated statistics. Here's the roster, bestie:
cpuβsg_cpu_stats,sg_cpu_percentsdiskβsg_disk_io_stats,sg_fs_statsloadβsg_load_statsmemβsg_mem_statsnetworkβsg_network_io_stats,sg_network_iface_statsosβsg_host_infopageβsg_page_statsprocessβsg_process_stats,sg_process_countswapβsg_swap_statsuserβsg_user_stats
The library was originally written to support the i-scream central monitoring system, but it has since become a standalone package. It has been ported to work on Linux, NetBSD, FreeBSD, OpenBSD, DragonFly BSD, Solaris, HP-UX, AIX and Cygwin. iconic behavior, honestly π.
π SEE ALSO π
go read these next β the whole squad is here:
sg_intro(3)sg_get_cpu_stats(3)sg_get_disk_io_stats(3)sg_get_fs_stats(3)sg_get_host_info(3)sg_get_load_stats(3)sg_get_mem_stats(3)sg_get_network_io_stats(3)sg_get_network_iface_stats(3)sg_get_page_stats(3)sg_get_process_stats(3)sg_get_swap_stats(3)sg_get_user_stats(3)sg_get_error(3)sg_internal-intro(3)
π WEBSITE π
the official site is https://libstatgrab.org/ β go touch some docs π.
cute sign-off: this page's source/version islibstatgrab, the date is2019-03-08, and the manual islibstatgrab(3)β periodt π β¨
π¦ where this page comes from
- alpine 3.24: libstatgrab-doc 0.92.1-r1 Β· LGPL-2.0-or-later
- arch rolling: libstatgrab 0.92.1-2 Β· LGPL AND GPL
- fedora 43: statgrab 1:0.92.1-14.fc43 Β· GPL-2.0-or-later
- fedora 44: statgrab 1:0.92.1-15.fc44 Β· GPL-2.0-or-later
- nixos 26.05: libstatgrab 0.92.1
- nixpkgs unstable: libstatgrab 0.92.1
- opensuse-leap 16.0: libstatgrab-devel 0.92.1-bp160.1.14 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: libstatgrab-devel 0.92.1-bp160.1.14 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: libstatgrab-devel 0.92.1-bp160.1.14 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: libstatgrab-devel 0.92.1-bp160.1.14 Β· LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms