1SYSINFO(2) Linux Programmer's Manual SYSINFO(2)
2
3
4
6 sysinfo - returns information on overall system statistics
7
9 #include <sys/sysinfo.h>
10
11 int sysinfo(struct sysinfo *info);
12
14 Until Linux 2.3.16, sysinfo() used to return information in the follow‐
15 ing structure:
16
17 struct sysinfo {
18 long uptime; /* Seconds since boot */
19 unsigned long loads[3]; /* 1, 5, and 15 minute load averages */
20 unsigned long totalram; /* Total usable main memory size */
21 unsigned long freeram; /* Available memory size */
22 unsigned long sharedram; /* Amount of shared memory */
23 unsigned long bufferram; /* Memory used by buffers */
24 unsigned long totalswap; /* Total swap space size */
25 unsigned long freeswap; /* swap space still available */
26 unsigned short procs; /* Number of current processes */
27 char _f[22]; /* Pads structure to 64 bytes */
28 };
29
30 and the sizes were given in bytes.
31
32 Since Linux 2.3.23 (i386), 2.3.48 (all architectures) the structure is:
33
34 struct sysinfo {
35 long uptime; /* Seconds since boot */
36 unsigned long loads[3]; /* 1, 5, and 15 minute load averages */
37 unsigned long totalram; /* Total usable main memory size */
38 unsigned long freeram; /* Available memory size */
39 unsigned long sharedram; /* Amount of shared memory */
40 unsigned long bufferram; /* Memory used by buffers */
41 unsigned long totalswap; /* Total swap space size */
42 unsigned long freeswap; /* swap space still available */
43 unsigned short procs; /* Number of current processes */
44 unsigned long totalhigh; /* Total high memory size */
45 unsigned long freehigh; /* Available high memory size */
46 unsigned int mem_unit; /* Memory unit size in bytes */
47 char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding for libc5 */
48 };
49
50 and the sizes are given as multiples of mem_unit bytes.
51
52 sysinfo() provides a simple way of getting overall system statistics.
53 This is more portable than reading /dev/kmem.
54
56 On success, zero is returned. On error, -1 is returned, and errno is
57 set appropriately.
58
60 EFAULT pointer to struct sysinfo is invalid
61
63 This function is Linux-specific, and should not be used in programs
64 intended to be portable.
65
66 The Linux kernel has a sysinfo() system call since 0.98.pl6. Linux
67 libc contains a sysinfo() routine since 5.3.5, and glibc has one since
68 1.90.
69
71 proc(5)
72
74 This page is part of release 3.25 of the Linux man-pages project. A
75 description of the project, and information about reporting bugs, can
76 be found at http://www.kernel.org/doc/man-pages/.
77
78
79
80Linux 2007-11-15 SYSINFO(2)