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

# statgrab(3)

get system statistics

## NAME

statgrab, libstatgrab - get system statistics

## SYNOPSIS

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

FCsg\_error **sg\_init**F\[0\]  FC(int *ignore\_init\_errors*);F\[0\]

FCsg\_error **sg\_shutdown**F\[0\]  FC(void);F\[0\]

FCsg\_error **sg\_drop\_privileges**F\[0\]  FC(void);F\[0\]

FCsg\_error **sg\_get\_error**F\[0\]  FC(void);F\[0\]

FCconst char \***sg\_get\_error\_arg**F\[0\]  FC(void);F\[0\]

FCint **sg\_get\_error\_errno**F\[0\]  FC(void);F\[0\]

FCconst char \***sg\_str\_error**F\[0\]  FC(sg\_error *code*);F\[0\]

FCsg\_error **sg\_get\_error\_details**F\[0\]  FC(sg\_error\_details \**err\_details*);F\[0\]

FCchar \***sg\_strperror**F\[0\]  FC(char \*\**buf*, const sg\_error\_details \* const *err\_details*);F\[0\]

FCsize\_t **sg\_get\_nelements**F\[0\]  FC(const void \**data*);F\[0\]

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

FCsg\_error **sg\_lock\_mutex**F\[0\]  FC(const char \**mutex\_name*);F\[0\]

FCsg\_error **sg\_unlock\_mutex**F\[0\]  FC(const char \**mutex\_name*);F\[0\]

FCsg\_cpu\_percents \***sg\_get\_cpu\_percents**F\[0\]  FC(void);F\[0\]

FCsg\_cpu\_percents \***sg\_get\_cpu\_percents\_of**F\[0\]  FC(sg\_cpu\_percent\_source *cps*);F\[0\]

FCsg\_cpu\_percents \***sg\_get\_cpu\_percents\_r**F\[0\]  FC(const sg\_cpu\_stats \**whereof*);F\[0\]

FCvoid **sg\_free\_cpu\_percents**F\[0\]  FC(sg\_cpu\_percents \**data*);F\[0\]

FCsg\_cpu\_stats \***sg\_get\_cpu\_stats**F\[0\]  FC(void);F\[0\]

FCsg\_cpu\_stats \***sg\_get\_cpu\_stats\_diff**F\[0\]  FC(void);F\[0\]

FCsg\_cpu\_stats \***sg\_get\_cpu\_stats\_r**F\[0\]  FC(void);F\[0\]

FCsg\_cpu\_stats \***sg\_get\_cpu\_stats\_diff\_between**F\[0\]  FC(const sg\_cpu\_stats \**cpu\_now*, const sg\_cpu\_stats \**cpu\_last*);F\[0\]

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

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

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

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

FCsg\_disk\_io\_stats \***sg\_get\_disk\_io\_stats\_diff\_between**F\[0\]  FC(const sg\_disk\_io\_stats \**cur*, const sg\_disk\_io\_stats \**last*, size\_t \**entries*);F\[0\]

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

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

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

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

FCconst char \*\***sg\_get\_valid\_filesystems**F\[0\]  FC(size\_t \**entries*);F\[0\]

FCsg\_error **sg\_set\_valid\_filesystems**F\[0\]  FC(const char \**valid\_fs*\[\]);F\[0\]

FCsg\_host\_info \***sg\_get\_host\_info**F\[0\]  FC(void);F\[0\]

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

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

FCsg\_load\_stats \***sg\_get\_load\_stats**F\[0\]  FC(void);F\[0\]

FCsg\_load\_stats \***sg\_get\_load\_stats**F\[0\]  FC(void);F\[0\]

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

FCsg\_mem\_stats \***sg\_get\_mem\_stats**F\[0\]  FC(void);F\[0\]

FCsg\_mem\_stats \***sg\_get\_mem\_stats\_r**F\[0\]  FC(void);F\[0\]

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

FCsg\_swap\_stats \***sg\_get\_swap\_stats**F\[0\]  FC(void);F\[0\]

FCsg\_swap\_stats \***sg\_get\_swap\_stats\_r**F\[0\]  FC(void);F\[0\]

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

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

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

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

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

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

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

FCsg\_network\_io\_stats \***sg\_get\_network\_io\_stats\_diff\_between**F\[0\]  FC(const sg\_network\_io\_stats \**cur*, const sg\_network\_io\_stats \**last*, size\_t \**entries*);F\[0\]

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

FCsg\_page\_stats \***sg\_get\_page\_stats**F\[0\]  FC(void);F\[0\]

FCsg\_page\_stats \***sg\_get\_page\_stats\_r**F\[0\]  FC(void);F\[0\]

FCsg\_page\_stats \***sg\_get\_page\_stats\_diff**F\[0\]  FC(void);F\[0\]

FCsg\_page\_stats \***sg\_get\_page\_stats\_diff\_between**F\[0\]  FC(const sg\_page\_stats \**cur*, const sg\_page\_stats \**last*);F\[0\]

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

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

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

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

FCsg\_process\_count \***sg\_get\_process\_count**F\[0\]  FC(void);F\[0\]

FCsg\_process\_count \***sg\_get\_process\_count\_of**F\[0\]  FC(sg\_process\_count\_source *pcs*);F\[0\]

FCsg\_process\_count \***sg\_get\_process\_count\_r**F\[0\]  FC(sg\_process\_stats const \**whereof*);F\[0\]

FCsg\_error **sg\_free\_process\_count**F\[0\]  FC(sg\_process\_count \**data*);F\[0\]

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

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

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

## DESCRIPTION

The statgrab library provides a cross-platform interface to get several system statistics. System statistics aren't standardised, so the statgrab library tries to choose the most important values over all supported operating systems. This implies that some values might not be available on every OS while some specific values are missing when there are no counterparts on any other OS.

The libstatgrab is organised in components, each for interrelated statistics.

| | |
| --- | --- |
| component | statistics |
| cpu | FCsg\_cpu\_statsF\[0\], FCsg\_cpu\_percentsF\[0\] |
| disk | FCsg\_disk\_io\_statsF\[0\], FCsg\_fs\_statsF\[0\] |
| load | FCsg\_load\_statsF\[0\] |
| mem | FCsg\_mem\_statsF\[0\] |
| network | FCsg\_network\_io\_statsF\[0\], FCsg\_network\_iface\_statsF\[0\] |
| os | FCsg\_host\_infoF\[0\] |
| page | FCsg\_page\_statsF\[0\] |
| process | FCsg\_process\_statsF\[0\], FCsg\_process\_countF\[0\] |
| swap | FCsg\_swap\_statsF\[0\] |
| user | FCsg\_user\_statsF\[0\] |

The library was originally written to support the i-scream central monitoring system, but has since become a standalone package. It has been ported to work on Linux, NetBSD, FreeBSD, OpenBSD, DragonFly BSD, Solaris, HP-UX, AIX and Cygwin.

## SEE ALSO

[**sg\_intro**(3)](/sg_intro/3.md) [**sg\_get\_cpu\_stats**(3)](/sg_get_cpu_stats/3.md) [**sg\_get\_disk\_io\_stats**(3)](/sg_get_disk_io_stats/3.md) [**sg\_get\_fs\_stats**(3)](/sg_get_fs_stats/3.md) [**sg\_get\_host\_info**(3)](/sg_get_host_info/3.md) [**sg\_get\_load\_stats**(3)](/sg_get_load_stats/3.md) [**sg\_get\_mem\_stats**(3)](/sg_get_mem_stats/3.md) [**sg\_get\_network\_io\_stats**(3)](/sg_get_network_io_stats/3.md) [**sg\_get\_network\_iface\_stats**(3)](/sg_get_network_iface_stats/3.md) [**sg\_get\_page\_stats**(3)](/sg_get_page_stats/3.md) [**sg\_get\_process\_stats**(3)](/sg_get_process_stats/3.md) [**sg\_get\_swap\_stats**(3)](/sg_get_swap_stats/3.md) [**sg\_get\_user\_stats**(3)](/sg_get_user_stats/3.md) [**sg\_get\_error**(3)](/sg_get_error/3.md) [**sg\_internal-intro**(3)](/sg_internal-intro/3.md)

## WEBSITE

⟨https://libstatgrab.org/⟩
