Blame man2/sysinfo.2

Packit 7cfc04
.\" Copyright (C) 2016, Michael Kerrisk <mtk.manpages@gmail.com>
Packit 7cfc04
.\" Based on an earlier version of the page where a few pieces were
Packit 7cfc04
.\" copyright (C) 1993 by Dan Miner (dminer@nyx.cs.du.edu) and subsequently
Packit 7cfc04
.\" others (see old changelog below).
Packit 7cfc04
.\" The structure definitions are taken more or less straight from the kernel
Packit 7cfc04
.\" source files.
Packit 7cfc04
.\"
Packit 7cfc04
.\" %%%LICENSE_START(VERBATIM)
Packit 7cfc04
.\" Permission is granted to make and distribute verbatim copies of this
Packit 7cfc04
.\" manual provided the copyright notice and this permission notice are
Packit 7cfc04
.\" preserved on all copies.
Packit 7cfc04
.\"
Packit 7cfc04
.\" Permission is granted to copy and distribute modified versions of this
Packit 7cfc04
.\" manual under the conditions for verbatim copying, provided that the
Packit 7cfc04
.\" entire resulting derived work is distributed under the terms of a
Packit 7cfc04
.\" permission notice identical to this one.
Packit 7cfc04
.\"
Packit 7cfc04
.\" Since the Linux kernel and libraries are constantly changing, this
Packit 7cfc04
.\" manual page may be incorrect or out-of-date.  The author(s) assume no
Packit 7cfc04
.\" responsibility for errors or omissions, or for damages resulting from
Packit 7cfc04
.\" the use of the information contained herein.  The author(s) may not
Packit 7cfc04
.\" have taken the same level of care in the production of this manual,
Packit 7cfc04
.\" which is licensed free of charge, as they might when working
Packit 7cfc04
.\" professionally.
Packit 7cfc04
.\"
Packit 7cfc04
.\" Formatted or processed versions of this manual, if unaccompanied by
Packit 7cfc04
.\" the source, must acknowledge the copyright and authors of this work.
Packit 7cfc04
.\" %%%LICENSE_END
Packit 7cfc04
.\"
Packit 7cfc04
.\"
Packit 7cfc04
.\" Modified Sat Jul 24 12:35:12 1993 by Rik Faith <faith@cs.unc.edu>
Packit 7cfc04
.\" Modified Tue Oct 22 22:29:51 1996 by Eric S. Raymond <esr@thyrsus.com>
Packit 7cfc04
.\" Modified Mon Aug 25 16:06:11 1997 by Nicolás Lichtmaier <nick@debian.org>
Packit 7cfc04
.\"
Packit 7cfc04
.TH SYSINFO 2 2017-09-15 "Linux" "Linux Programmer's Manual"
Packit 7cfc04
.SH NAME
Packit 7cfc04
sysinfo \- return system information
Packit 7cfc04
.SH SYNOPSIS
Packit 7cfc04
.B #include <sys/sysinfo.h>
Packit 7cfc04
.PP
Packit 7cfc04
.BI "int sysinfo(struct sysinfo *" info );
Packit 7cfc04
.SH DESCRIPTION
Packit 7cfc04
.BR sysinfo ()
Packit 7cfc04
returns certain statistics on memory and swap usage,
Packit 7cfc04
as well as the load average.
Packit 7cfc04
.PP
Packit 7cfc04
Until Linux 2.3.16,
Packit 7cfc04
.BR sysinfo ()
Packit 7cfc04
returned information in the following structure:
Packit 7cfc04
.PP
Packit 7cfc04
.in +4n
Packit 7cfc04
.EX
Packit 7cfc04
struct sysinfo {
Packit 7cfc04
    long uptime;             /* Seconds since boot */
Packit 7cfc04
    unsigned long loads[3];  /* 1, 5, and 15 minute load averages */
Packit 7cfc04
    unsigned long totalram;  /* Total usable main memory size */
Packit 7cfc04
    unsigned long freeram;   /* Available memory size */
Packit 7cfc04
    unsigned long sharedram; /* Amount of shared memory */
Packit 7cfc04
    unsigned long bufferram; /* Memory used by buffers */
Packit 7cfc04
    unsigned long totalswap; /* Total swap space size */
Packit 7cfc04
    unsigned long freeswap;  /* Swap space still available */
Packit 7cfc04
    unsigned short procs;    /* Number of current processes */
Packit 7cfc04
    char _f[22];             /* Pads structure to 64 bytes */
Packit 7cfc04
};
Packit 7cfc04
.EE
Packit 7cfc04
.in
Packit 7cfc04
.PP
Packit 7cfc04
In the above structure, the sizes of the memory and swap fields
Packit 7cfc04
are given in bytes.
Packit 7cfc04
.PP
Packit 7cfc04
Since Linux 2.3.23 (i386) and Linux 2.3.48
Packit 7cfc04
(all architectures) the structure is:
Packit 7cfc04
.PP
Packit 7cfc04
.in +4n
Packit 7cfc04
.EX
Packit 7cfc04
struct sysinfo {
Packit 7cfc04
    long uptime;             /* Seconds since boot */
Packit 7cfc04
    unsigned long loads[3];  /* 1, 5, and 15 minute load averages */
Packit 7cfc04
    unsigned long totalram;  /* Total usable main memory size */
Packit 7cfc04
    unsigned long freeram;   /* Available memory size */
Packit 7cfc04
    unsigned long sharedram; /* Amount of shared memory */
Packit 7cfc04
    unsigned long bufferram; /* Memory used by buffers */
Packit 7cfc04
    unsigned long totalswap; /* Total swap space size */
Packit 7cfc04
    unsigned long freeswap;  /* Swap space still available */
Packit 7cfc04
    unsigned short procs;    /* Number of current processes */
Packit 7cfc04
    unsigned long totalhigh; /* Total high memory size */
Packit 7cfc04
    unsigned long freehigh;  /* Available high memory size */
Packit 7cfc04
    unsigned int mem_unit;   /* Memory unit size in bytes */
Packit 7cfc04
    char _f[20\-2*sizeof(long)\-sizeof(int)];
Packit 7cfc04
                             /* Padding to 64 bytes */
Packit 7cfc04
};
Packit 7cfc04
.EE
Packit 7cfc04
.in
Packit 7cfc04
.PP
Packit 7cfc04
In the above structure,
Packit 7cfc04
sizes of the memory and swap fields are given as multiples of
Packit 7cfc04
.I mem_unit
Packit 7cfc04
bytes.
Packit 7cfc04
.SH RETURN VALUE
Packit 7cfc04
On success,
Packit 7cfc04
.BR sysinfo ()
Packit 7cfc04
returns zero.
Packit 7cfc04
On error, \-1 is returned, and
Packit 7cfc04
.I errno
Packit 7cfc04
is set to indicate the cause of the error.
Packit 7cfc04
.SH ERRORS
Packit 7cfc04
.TP
Packit 7cfc04
.B EFAULT
Packit 7cfc04
.IR info
Packit 7cfc04
is not a valid address.
Packit 7cfc04
.SH VERSIONS
Packit 7cfc04
.BR sysinfo ()
Packit 7cfc04
first appeared in Linux 0.98.pl6.
Packit 7cfc04
.SH CONFORMING TO
Packit 7cfc04
This function is Linux-specific, and should not be used in programs
Packit 7cfc04
intended to be portable.
Packit 7cfc04
.SH NOTES
Packit 7cfc04
All of the information provided by this system call is also available via
Packit 7cfc04
.IR /proc/meminfo
Packit 7cfc04
and
Packit 7cfc04
.IR /proc/loadavg .
Packit 7cfc04
.SH SEE ALSO
Packit 7cfc04
.BR proc (5)
Packit 7cfc04
.SH COLOPHON
Packit 7cfc04
This page is part of release 4.15 of the Linux
Packit 7cfc04
.I man-pages
Packit 7cfc04
project.
Packit 7cfc04
A description of the project,
Packit 7cfc04
information about reporting bugs,
Packit 7cfc04
and the latest version of this page,
Packit 7cfc04
can be found at
Packit 7cfc04
\%https://www.kernel.org/doc/man\-pages/.