sg_get_host_info(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

✨ sg_get_host_info(3) β€” like, the whole manual page, bestie ✨

Okay so this is the sg_get_host_info(3) page from libstatgrab and it's literally about getting the tea on your operating system and the machine it's living on. Pull up a chair πŸŽ€


🌸 NAME 🌸

sg_get_host_info, sg_get_host_info_r, sg_free_host_info β€” get general operating system statistics. That's the whole vibe: OS stats, general ones, no cap.


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <statgrab.h>

sg_host_info *sg_get_host_info (size_t *entries);

sg_host_info *sg_get_host_info_r (size_t *entries);

sg_error sg_free_host_info (sg_host_info *data);

Three little functions, three little signatures, all copied exactly because I would never mess with your headers πŸ’…


πŸ’– DESCRIPTION πŸ’–

These calls return details on the operating system and the machine it's running on. Like a vibe check for your whole computer ✨

🧚 API Shortcut

So the original had a whole cute table and I'm gonna give it to you as a list because we're in a terminal and tables are giving "spreadsheet from 2004" lowkey:

  • sg_get_host_info β†’ returns sg_host_info * β†’ data owner is libstatgrab (thread local). It handles its own business, you don't gotta do a thing 🫢
  • sg_get_host_info_r β†’ returns sg_host_info * β†’ data owner is the caller. That's you. You own it. Main character responsibility 😭
The sg_host_info buffer received from sg_get_host_info_r() must be freed using sg_free_host_info() when not needed any more. The caller is responsible for doing it. Fr fr, don't forget or that's a leak bestie πŸ’€

πŸ‘‘ RETURN VALUES πŸ‘‘

The structure returned is of type sg_host_info. Here's the enum and the struct, verbatim, no edits, slay:

typedef enum {
        sg_unknown_configuration = 0,
        sg_physical_host,
        sg_virtual_machine,
        sg_paravirtual_machine,
        sg_hardware_virtualized
} sg_host_state;

typedef struct{
        char *os_name;
        char *os_release;
        char *os_version;
        char *platform;
        char *hostname;
        unsigned bitwidth;
        sg_host_state host_state;
        unsigned ncpus;
        unsigned maxcpus;
        time_t uptime;
        time_t systime;
}sg_host_info;

And now the field-by-field breakdown, because every single one matters πŸ“

  • os_name β€” the operating system name. (eg. SunOS or Linux)
  • os_release β€” the operating system release. (eg. 5.8 or 5.9 or Solaris)
  • os_version β€” the version level of the OS.
  • platform β€” the hardware platform (architecture) the OS runs on.
  • hostname β€” the name of the machine.
  • uptime β€” the uptime of the machine in seconds.
  • systime β€” the timestamp when the above stats where collected in seconds since epoch. (Yes, "where" β€” that's how the original spells it and I'm not gonna gaslight you by fixing it πŸ™ˆ)
Not me just noticing bitwidth, host_state, ncpus and maxcpus are literally in the struct but the original page doesn't give them their own little description paragraphs. They're there, they're in the struct, that's the facts β€” I'm not gonna make up behaviour for them πŸ’œ

πŸ”₯ SEE ALSO πŸ”₯


🌈 WEBSITE 🌈

The official site, as listed: https://libstatgrab.org/ πŸ‘‘


And that's the whole page, bestie β€” no details left behind, every flag and field accounted for ✨ This was libstatgrab, dated 2019-03-08, and it's the sg_get_host_info(3) manual page signing off. Periodt πŸ’…πŸŽ€