Name

sysinfo — return system information

Synopsis

        #include <sys/sysinfo.h>
int sysinfo( struct sysinfo *info);
 

DESCRIPTION

sysinfo() returns certain statistics on memory and swap usage, as well as the load average.

Until Linux 2.3.16, sysinfo() returned information in the following structure:

struct sysinfo {
  long   uptime;
/* Seconds since boot */
  unsigned long   loads[3];
/* 1, 5, and 15 minute load averages */
  unsigned long   totalram;
/* Total usable main memory size */
  unsigned long   freeram;
/* Available memory size */
  unsigned long   sharedram;
/* Amount of shared memory */
  unsigned long   bufferram;
/* Memory used by buffers */
  unsigned long   totalswap;
/* Total swap space size */
  unsigned long   freeswap;
/* Swap space still available */
  unsigned short   procs;
/* Number of current processes */
  char   _f[22];
/* Pads structure to 64 bytes */
};

In the above structure, the sizes of the memory and swap fields are given in bytes.

Since Linux 2.3.23 (i386) and Linux 2.3.48 (all architectures) the structure is:

struct sysinfo {
    long uptime;             /* Seconds since boot */
    unsigned long loads[3];  /* 1, 5, and 15 minute load averages */
    unsigned long totalram;  /* Total usable main memory size */
    unsigned long freeram;   /* Available memory size */
    unsigned long sharedram; /* Amount of shared memory */
    unsigned long bufferram; /* Memory used by buffers */
    unsigned long totalswap; /* Total swap space size */
    unsigned long freeswap;  /* Swap space still available */
    unsigned short procs;    /* Number of current processes */
    unsigned long totalhigh; /* Total high memory size */
    unsigned long freehigh;  /* Available high memory size */
    unsigned int mem_unit;   /* Memory unit size in bytes */
    char _f[20−2*sizeof(long)−sizeof(int)];
                             /* Padding to 64 bytes */
};

In the above structure, sizes of the memory and swap fields are given as multiples of mem_unit bytes.

RETURN VALUE

On success, sysinfo() returns zero. On error, −1 is returned, and errno is set to indicate the cause of the error.

ERRORS

EFAULT

info is not a valid address.

VERSIONS

sysinfo() first appeared in Linux 0.98.pl6.

CONFORMING TO

This function is Linux-specific, and should not be used in programs intended to be portable.

NOTES

All of the information provided by this system call is also available via /proc/meminfo and /proc/loadavg.

SEE ALSO

proc(5)

COLOPHON

This page is part of release 4.07 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at https://www.kernel.org/doc/man−pages/.


  Copyright (C) 2016, Michael Kerrisk <mtk.manpagesgmail.com>
Based on an earlier version of the page where a few pieces were
copyright (C) 1993 by Dan Miner (dminernyx.cs.du.edu) and subsequently
others (see old changelog below).
The structure definitions are taken more or less straight from the kernel
source files.

%%%LICENSE_START(VERBATIM)
Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
preserved on all copies.

Permission is granted to copy and distribute modified versions of this
manual under the conditions for verbatim copying, provided that the
entire resulting derived work is distributed under the terms of a
permission notice identical to this one.

Since the Linux kernel and libraries are constantly changing, this
manual page may be incorrect or out-of-date.  The author(s) assume no
responsibility for errors or omissions, or for damages resulting from
the use of the information contained herein.  The author(s) may not
have taken the same level of care in the production of this manual,
which is licensed free of charge, as they might when working
professionally.

Formatted or processed versions of this manual, if unaccompanied by
the source, must acknowledge the copyright and authors of this work.
%%%LICENSE_END


Modified Sat Jul 24 12:35:12 1993 by Rik Faith <faithcs.unc.edu>
Modified Tue Oct 22 22:29:51 1996 by Eric S. Raymond <esrthyrsus.com>
Modified Mon Aug 25 16:06:11 1997 by Nicolás Lichtmaier <nickdebian.org>