---
name: "sg_get_host_info"
section: "3"
platform: "linux"
package: "libstatgrab"
version: "0.92.1-2"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/sg_get_host_info"
---

# sg\_get\_host\_info(3)

get general operating system statistics

## 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[0]
```

FCsg\_host\_info \***sg\_get\_host\_info**F\[0\]  FC(size\_t \**entries*);F\[0\]

FCsg\_host\_info \***sg\_get\_host\_info\_r**F\[0\]  FC(size\_t \**entries*);F\[0\]

FCsg\_error **sg\_free\_host\_info**F\[0\]  FC(sg\_host\_info \**data*);F\[0\]

## 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\_infoF\[0\] \* | libstatgrab (thread local) |
| sg\_get\_host\_info\_r | FCsg\_host\_infoF\[0\] \* | caller |

The FCsg\_host\_infoF\[0\] buffer received from FC**sg\_get\_host\_info\_r**F\[0\]() must be freed using FC**sg\_free\_host\_info**F\[0\]() when not needed any more. The caller is responsible for doing it.

## RETURN VALUES

The structure returned is of type FCsg\_host\_infoF\[0\].

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

```
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[0]
```

- FCos\_nameF\[0\]

  The operating system name. (eg. SunOS or Linux)

- FCos\_releaseF\[0\]

  The operating system release. (eg. 5.8 or 5.9 or Solaris)

- FCos\_versionF\[0\]

  The version level of the OS.

- FCplatformF\[0\]

  The hardware platform (architecture) the OS runs on.

- FChostnameF\[0\]

  The name of the machine.

- FCuptimeF\[0\]

  The uptime of the machine in seconds.

- FCsystimeF\[0\]

  The timestamp when the above stats where collected in seconds since epoch

## SEE ALSO

[**statgrab**(3)](/statgrab/3.md)

## WEBSITE

⟨https://libstatgrab.org/⟩
