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. Since Linux 2.3.23 (i386), 2.3.48
31 (all architectures) the structure is
32
33 struct sysinfo {
34 long uptime; /* Seconds since boot */
35 unsigned long loads[3]; /* 1, 5, and 15 minute load averages */
36 unsigned long totalram; /* Total usable main memory size */
37 unsigned long freeram; /* Available memory size */
38 unsigned long sharedram; /* Amount of shared memory */
39 unsigned long bufferram; /* Memory used by buffers */
40 unsigned long totalswap; /* Total swap space size */
41 unsigned long freeswap; /* swap space still available */
42 unsigned short procs; /* Number of current processes */
43 unsigned long totalhigh; /* Total high memory size */
44 unsigned long freehigh; /* Available high memory size */
45 unsigned int mem_unit; /* Memory unit size in bytes */
46 char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding for libc5 */
47 };
48
49 and the sizes are given as multiples of mem_unit bytes.
50
51 sysinfo() provides a simple way of getting overall system statistics.
52 This is more portable than reading /dev/kmem. For an example of its
53 use, see intro(2).
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
73
74
75Linux 2.0 1997-08-25 SYSINFO(2)