---
name: "sg_get_load_stats"
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_load_stats"
---

# sg\_get\_load\_stats(3)

get system load

## NAME

sg\_get\_load\_stats, sg\_get\_load\_stats\_r, sg\_free\_load\_stats - get system load

## SYNOPSIS

```
FC#include <statgrab.h>F[0]
```

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

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

FCsg\_error **sg\_free\_load\_stats**F\[0\]  FC(sg\_load\_stats \**data*);F\[0\]

## DESCRIPTION

These calls returns a pointer to a buffer containing information about cumulated machine load.

**API Shortcut**

| | | |
| --- | --- | --- |
| function | returns | data owner |
| sg\_get\_load\_stats | FCsg\_load\_statsF\[0\] \* | libstatgrab (thread local) |
| sg\_get\_load\_stats\_r | FCsg\_load\_statsF\[0\] \* | caller |

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

On most systems this function is just a wrapper to the FC**getloadavg**F\[0\] system call.

## RETURN VALUES

The structure returned is of type FCsg\_load\_statsF\[0\].

```
FC
typedef struct{
        double min1;
        double min5;
        double min15;
        time_t systime;
}sg_load_stats;
    F[0]
```

- FCmin1F\[0\]

  The load average over 1 minute.

- FCmin5F\[0\]

  The load average over 5 minutes.

- FCmin15F\[0\]

  The load average over 15 minutes.

- 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/⟩
