sg_get_host_info(3)

NAME
sg_get_host_info, sg_get_host_info_r, sg_free_host_info - get general operating system statistics

SYNOPSIS
\FC#include <statgrab.h>\F[]

\FCsg_host_info *sg_get_host_info\F[]
\FC(size_t *entries);\F[]

\FCsg_host_info *sg_get_host_info_r\F[]
\FC(size_t *entries);\F[]

\FCsg_error sg_free_host_info\F[]
\FC(sg_host_info *data);\F[]

DESCRIPTION
These calls return details on the operating system and the machine it's running on.

API Shortcut
function | returns | data owner
sg_get_host_info | \FCsg_host_info\F[] * | libstatgrab (thread local)
sg_get_host_info_r | \FCsg_host_info\F[] * | caller

The \FCsg_host_info\F[] buffer received from \FCsg_get_host_info_r\F[]() must be freed using \FCsg_free_host_info\F[]() when not needed any more. The caller is responsible for doing it.

RETURN VALUES
The structure returned is of type \FCsg_host_info\F[].

\FC
typedef enum {
        sg_unknown_configuration = 0,
        sg_physical_host,
        sg_virtual_machine,
        sg_paravirtual_machine,
        sg_hardware_virtualized
} sg_host_state;
    \F[]

\FC
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;
    \F[]

\FCos_name\F[]
    The operating system name. (eg. SunOS or Linux)

\FCos_release\F[]
    The operating system release. (eg. 5.8 or 5.9 or Solaris)

\FCos_version\F[]
    The version level of the OS.

\FCplatform\F[]
    The hardware platform (architecture) the OS runs on.

\FChostname\F[]
    The name of the machine.

\FCuptime\F[]
    The uptime of the machine in seconds.

\FCsystime\F[]
    The timestamp when the above stats where collected in seconds since epoch

SEE ALSO
statgrab(3)

WEBSITE
⟨https://libstatgrab.org/⟩