sg_get_load_stats(3)

πŸ“¦
version 0.92.1 Β· 2 versions
, in alpine 3.24, arch rolling, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0

okay bestie, this is the sg_get_load_stats(3) page from the libstatgrab manual β€” manual name folded right in near the top so we don’t have to copy the header line like an NPC. πŸ’…βœ¨

πŸ’– NAME πŸ’–

sg_get_load_stats, sg_get_load_stats_r, sg_free_load_stats β€” get system load. that’s the whole assignment, bestie. πŸ’–

πŸŽ€ SYNOPSIS πŸŽ€

#include <statgrab.h>

sg_load_stats *sg_get_load_stats (size_t *entries);

sg_load_stats *sg_get_load_stats_r (size_t *entries);

sg_error sg_free_load_stats (sg_load_stats *data);

πŸ¦‹ DESCRIPTION πŸ¦‹

These calls hand you back a pointer to a buffer that’s full of info about cumulated machine load. lowkey iconic for checking how busy your machine is. ✨

⚑ API Shortcut ⚑

  • sg_get_load_stats β€” returns sg_load_stats *; data owner is libstatgrab (thread local).
  • sg_get_load_stats_r β€” returns sg_load_stats *; data owner is the caller.

so, real talk: the sg_load_stats buffer you get from sg_get_load_stats_r() must be freed using sg_free_load_stats() when it’s not needed any more. The caller is responsible for doing it. that means you, bestie β€” no ghosting your memory. πŸ˜­πŸ’…

On most systems this function is just a wrapper to the getloadavg system call. fr fr.

🌈 RETURN VALUES 🌈

The structure returned is of type sg_load_stats.

typedef struct{
        double min1;
        double min5;
        double min15;
        time_t systime;
}sg_load_stats;
  • min1 β€” The load average over 1 minute.
  • min5 β€” The load average over 5 minutes.
  • min15 β€” The load average over 15 minutes.
  • systime β€” The timestamp when the above stats were collected, in seconds since epoch.

🫢 SEE ALSO 🫢

  • statgrab(3) β€” the friend you should also check out, iykyk.

🌐 WEBSITE 🌐


k bye bestie πŸŽ€ this one’s from libstatgrab, dated 2019-03-08, and it’s the sg_get_load_stats(3) manual page. mwah πŸ’‹