]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man2/sysinfo.2
Various pages: [Linux-man-pages-copyleft] Use SPDX-License-Identifier
[thirdparty/man-pages.git] / man2 / sysinfo.2
1 .\" Copyright (C) 2016, Michael Kerrisk <mtk.manpages@gmail.com>
2 .\" Based on an earlier version of the page where a few pieces were
3 .\" copyright (C) 1993 by Dan Miner (dminer@nyx.cs.du.edu) and subsequently
4 .\" others (see old changelog below).
5 .\" The structure definitions are taken more or less straight from the kernel
6 .\" source files.
7 .\"
8 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
9 .\"
10 .\"
11 .\" Modified Sat Jul 24 12:35:12 1993 by Rik Faith <faith@cs.unc.edu>
12 .\" Modified Tue Oct 22 22:29:51 1996 by Eric S. Raymond <esr@thyrsus.com>
13 .\" Modified Mon Aug 25 16:06:11 1997 by Nicolás Lichtmaier <nick@debian.org>
14 .\"
15 .TH SYSINFO 2 2021-03-22 "Linux" "Linux Programmer's Manual"
16 .SH NAME
17 sysinfo \- return system information
18 .SH SYNOPSIS
19 .nf
20 .B #include <sys/sysinfo.h>
21 .PP
22 .BI "int sysinfo(struct sysinfo *" info );
23 .fi
24 .SH DESCRIPTION
25 .BR sysinfo ()
26 returns certain statistics on memory and swap usage,
27 as well as the load average.
28 .PP
29 Until Linux 2.3.16,
30 .BR sysinfo ()
31 returned information in the following structure:
32 .PP
33 .in +4n
34 .EX
35 struct sysinfo {
36 long uptime; /* Seconds since boot */
37 unsigned long loads[3]; /* 1, 5, and 15 minute load averages */
38 unsigned long totalram; /* Total usable main memory size */
39 unsigned long freeram; /* Available memory size */
40 unsigned long sharedram; /* Amount of shared memory */
41 unsigned long bufferram; /* Memory used by buffers */
42 unsigned long totalswap; /* Total swap space size */
43 unsigned long freeswap; /* Swap space still available */
44 unsigned short procs; /* Number of current processes */
45 char _f[22]; /* Pads structure to 64 bytes */
46 };
47 .EE
48 .in
49 .PP
50 In the above structure, the sizes of the memory and swap fields
51 are given in bytes.
52 .PP
53 Since Linux 2.3.23 (i386) and Linux 2.3.48
54 (all architectures) the structure is:
55 .PP
56 .in +4n
57 .EX
58 struct sysinfo {
59 long uptime; /* Seconds since boot */
60 unsigned long loads[3]; /* 1, 5, and 15 minute load averages */
61 unsigned long totalram; /* Total usable main memory size */
62 unsigned long freeram; /* Available memory size */
63 unsigned long sharedram; /* Amount of shared memory */
64 unsigned long bufferram; /* Memory used by buffers */
65 unsigned long totalswap; /* Total swap space size */
66 unsigned long freeswap; /* Swap space still available */
67 unsigned short procs; /* Number of current processes */
68 unsigned long totalhigh; /* Total high memory size */
69 unsigned long freehigh; /* Available high memory size */
70 unsigned int mem_unit; /* Memory unit size in bytes */
71 char _f[20\-2*sizeof(long)\-sizeof(int)];
72 /* Padding to 64 bytes */
73 };
74 .EE
75 .in
76 .PP
77 In the above structure,
78 sizes of the memory and swap fields are given as multiples of
79 .I mem_unit
80 bytes.
81 .SH RETURN VALUE
82 On success,
83 .BR sysinfo ()
84 returns zero.
85 On error, \-1 is returned, and
86 .I errno
87 is set to indicate the error.
88 .SH ERRORS
89 .TP
90 .B EFAULT
91 .IR info
92 is not a valid address.
93 .SH VERSIONS
94 .BR sysinfo ()
95 first appeared in Linux 0.98.pl6.
96 .SH CONFORMING TO
97 This function is Linux-specific, and should not be used in programs
98 intended to be portable.
99 .SH NOTES
100 All of the information provided by this system call is also available via
101 .IR /proc/meminfo
102 and
103 .IR /proc/loadavg .
104 .SH SEE ALSO
105 .BR proc (5)