Debian Codegraph @

upstream/debian-unstable/man2/sysinfo.2

raw
1 .\" Copyright 1993, Dan Miner <[email protected]>
2 .\" Copyright 2016, Michael Kerrisk <[email protected]>
3 .\" Copyright, the authors of the Linux man-pages project
4 .\"
5 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .\"
7 .TH sysinfo 2 2026-02-08 "Linux man-pages 6.18"
8 .SH NAME
9 sysinfo \- return system information
10 .SH LIBRARY
11 Standard C library
12 .RI ( libc ,\~ \-lc )
13 .SH SYNOPSIS
14 .nf
15 .B #include <sys/sysinfo.h>
16 .P
17 .BI "int sysinfo(struct sysinfo *" info );
18 .fi
19 .SH DESCRIPTION
20 .BR sysinfo ()
21 returns certain statistics on memory and swap usage,
22 as well as the load average.
23 .P
24 Until Linux 2.3.16,
25 .BR sysinfo ()
26 returned information in the following structure:
27 .P
28 .in +4n
29 .EX
30 struct sysinfo {
31 long uptime; /* Seconds since boot */
32 unsigned long loads[3]; /* 1, 5, and 15 minute load averages */
33 unsigned long totalram; /* Total usable main memory size */
34 unsigned long freeram; /* Available memory size */
35 unsigned long sharedram; /* Amount of shared memory */
36 unsigned long bufferram; /* Memory used by buffers */
37 unsigned long totalswap; /* Total swap space size */
38 unsigned long freeswap; /* Swap space still available */
39 unsigned short procs; /* Number of current processes */
40 char _f[22]; /* Pads structure to 64 bytes */
41 };
42 .EE
43 .in
44 .P
45 In the above structure, the sizes of the memory and swap fields
46 are given in bytes.
47 .P
48 Since Linux 2.3.23 (i386) and Linux 2.3.48
49 (all architectures) the structure is:
50 .P
51 .in +4n
52 .EX
53 struct sysinfo {
54 long uptime; /* Seconds since boot */
55 unsigned long loads[3]; /* 1, 5, and 15 minute load averages */
56 unsigned long totalram; /* Total usable main memory size */
57 unsigned long freeram; /* Available memory size */
58 unsigned long sharedram; /* Amount of shared memory */
59 unsigned long bufferram; /* Memory used by buffers */
60 unsigned long totalswap; /* Total swap space size */
61 unsigned long freeswap; /* Swap space still available */
62 unsigned short procs; /* Number of current processes */
63 unsigned long totalhigh; /* Total high memory size */
64 unsigned long freehigh; /* Available high memory size */
65 unsigned int mem_unit; /* Memory unit size in bytes */
66 char _f[20\-2*sizeof(long)\-sizeof(int)];
67 /* Padding to 64 bytes */
68 };
69 .EE
70 .in
71 .P
72 In the above structure,
73 sizes of the memory and swap fields are given as multiples of
74 .I mem_unit
75 bytes.
76 .SH RETURN VALUE
77 On success,
78 .BR sysinfo ()
79 returns zero.
80 On error, \-1 is returned, and
81 .I errno
82 is set to indicate the error.
83 .SH ERRORS
84 .TP
85 .B EFAULT
86 .I info
87 is not a valid address.
88 .SH STANDARDS
89 Linux.
90 .SH HISTORY
91 Linux 0.98.pl6.
92 .SH NOTES
93 All of the information provided by this system call is also available via
94 .I /proc/meminfo
95 and
96 .IR /proc/loadavg .
97 .SH SEE ALSO
98 .BR proc (5)