sg_get_page_stats(3)
π sg_get_page_stats(3) π
okay so bestie, you opened the 3 manual page for sg_get_page_stats, and it's from that libstatgrab life. this whole page is about paging statistics and honestly? it's giving "small but mighty." let's get into it π«Ά
β¨ NAME β¨
sg_get_page_stats, sg_get_page_stats_r, sg_get_page_stats_diff, sg_get_page_stats_diff_between, sg_free_page_stats β get paging statistics. that's the whole vibe. π
π¦ SYNOPSIS π¦
#include <statgrab.h>
sg_page_stats *sg_get_page_stats (size_t *entries);
sg_page_stats *sg_get_page_stats_r (size_t *entries);
sg_page_stats *sg_get_page_stats_diff (size_t *entries);
sg_page_stats *sg_get_page_stats_diff_between (const sg_page_stats *cur,
const sg_page_stats *last, size_t *entries);
sg_error sg_free_page_stats (sg_page_stats *data);
like, look at all those functions. one big happy paging family. πΈ
π DESCRIPTION π
so the page stats module? it delivers the number of pages swapped in and out. that's it, that's the job. β¨
and it does it in two whole flavors:
- either since the machine has been booted β that's
sg_get_page_stats()andsg_get_page_stats_r()doing their thing - or the difference between two measured statistics β that's
sg_get_page_stats_diff()andsg_get_page_stats_diff_between()stepping in π₯
now, sg_get_page_stats_diff() is lowkey the interesting one. it calculates the difference between the last call to sg_get_page_stats() in this thread. and like, how? the statistics of the earlier call get saved, and sg_get_page_stats() is called immediately after that. it's doing the math for you, bestie. π
π« API Shortcut π«
no table energy today, so here's the same tea in list form β function, what it returns, and who owns the data:
sg_get_page_statsβ returnssg_page_stats *β data owner is libstatgrab (thread local)sg_get_page_stats_rβ returnssg_page_stats *β data owner is the callersg_get_page_stats_diffβ returnssg_page_stats *β data owner is libstatgrab (thread local)sg_get_page_stats_diff_betweenβ returnssg_page_stats *β data owner is the caller
and this part matters, okay? π¨ the sg_page_stats buffer you get from sg_get_page_stats_r() and from sg_get_page_stats_diff_between() must be freed using sg_free_page_stats() when you don't need it any more. the caller is responsible for doing it. that's you. you're the caller. don't forget. π
π RETURN VALUES π
here's the struct, iconic as ever:
typedef struct{
unsigned long long pages_pagein;
unsigned long long pages_pageout;
time_t systime;
}sg_page_stats;
and the fields, one by one:
pages_pageinβ the number of pages swapped into memory.pages_pageoutβ the number of pages swapped out of memory (to swap).systimeβ the timestamp when the above stats were collected, in seconds since epoch. or, the time period over whichpages_pageinandpages_pageoutwere transferred. two moods, same field. π¦
π BUGS π
Solaris doesn't seem to report accurately. it reports the number of pages swapped into memory, not necessarily from swap. this feature isn't deemed entirely reliable.
so yeah. on Solaris, take those numbers with a grain of salt. maybe two grains. π
π SEE ALSO π
statgrab(3)β go read it, bestie, iykyk π
πΈ WEBSITE πΈ
β¨https://libstatgrab.org/β© β the mothership. go say hi. β
and that's the page!! brought to you by libstatgrab, dated 2019-03-08, manual section 3, sg_get_page_stats(3) β mwah, slay, 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: libstatgrab-devel 1:0.92.1-14.fc43 Β· LGPL-2.1-or-later
- fedora 43: libstatgrab-devel 1:0.92.1-14.fc43 Β· LGPL-2.1-or-later
- fedora 44: libstatgrab-devel 1:0.92.1-15.fc44 Β· LGPL-2.1-or-later
- fedora 44: libstatgrab-devel 1:0.92.1-15.fc44 Β· LGPL-2.1-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