1sysinfo(2) System Calls Manual sysinfo(2)
2
3
4
6 sysinfo - return system information
7
9 Standard C library (libc, -lc)
10
12 #include <sys/sysinfo.h>
13
14 int sysinfo(struct sysinfo *info);
15
17 sysinfo() returns certain statistics on memory and swap usage, as well
18 as the load average.
19
20 Until Linux 2.3.16, sysinfo() returned information in the following
21 structure:
22
23 struct sysinfo {
24 long uptime; /* Seconds since boot */
25 unsigned long loads[3]; /* 1, 5, and 15 minute load averages */
26 unsigned long totalram; /* Total usable main memory size */
27 unsigned long freeram; /* Available memory size */
28 unsigned long sharedram; /* Amount of shared memory */
29 unsigned long bufferram; /* Memory used by buffers */
30 unsigned long totalswap; /* Total swap space size */
31 unsigned long freeswap; /* Swap space still available */
32 unsigned short procs; /* Number of current processes */
33 char _f[22]; /* Pads structure to 64 bytes */
34 };
35
36 In the above structure, the sizes of the memory and swap fields are
37 given in bytes.
38
39 Since Linux 2.3.23 (i386) and Linux 2.3.48 (all architectures) the
40 structure is:
41
42 struct sysinfo {
43 long uptime; /* Seconds since boot */
44 unsigned long loads[3]; /* 1, 5, and 15 minute load averages */
45 unsigned long totalram; /* Total usable main memory size */
46 unsigned long freeram; /* Available memory size */
47 unsigned long sharedram; /* Amount of shared memory */
48 unsigned long bufferram; /* Memory used by buffers */
49 unsigned long totalswap; /* Total swap space size */
50 unsigned long freeswap; /* Swap space still available */
51 unsigned short procs; /* Number of current processes */
52 unsigned long totalhigh; /* Total high memory size */
53 unsigned long freehigh; /* Available high memory size */
54 unsigned int mem_unit; /* Memory unit size in bytes */
55 char _f[20-2*sizeof(long)-sizeof(int)];
56 /* Padding to 64 bytes */
57 };
58
59 In the above structure, sizes of the memory and swap fields are given
60 as multiples of mem_unit bytes.
61
63 On success, sysinfo() returns zero. On error, -1 is returned, and er‐
64 rno is set to indicate the error.
65
67 EFAULT info is not a valid address.
68
70 Linux.
71
73 Linux 0.98.pl6.
74
76 All of the information provided by this system call is also available
77 via /proc/meminfo and /proc/loadavg.
78
80 proc(5)
81
82
83
84Linux man-pages 6.05 2023-03-30 sysinfo(2)