sysinfo

Autres langues

Langue: ja

Autres versions - même langue

Version: 1997-08-25 (fedora - 25/11/07)

Section: 2 (Appels système)

名前

sysinfo - システム全体の統計情報を返す。

書式

#include <sys/sysinfo.h>

int sysinfo(struct sysinfo *info);

説明

Linux 2.3.16 までは sysinfo() は以下の構造体に情報を入れて返す。
 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 */
 };
 

ここでバイト単位で与えられる。

Linux 2.3.23 (i386)、2.3.48 (全てのアーキテクチャ) からは構造体は

 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 for libc5 */
 };
 

となり、大きさは mem_unit バイトの倍数で与えられる。

sysinfo() はシステム全体の統計を取得する簡単な方法を提供する。 これは /dev/kmem を読むよりも移植性の高い方法である。 使用例は intro(2) を参照すること。

返り値

成功した場合はゼロが返される。エラーならば -1 が返され、 errno が適切に設定される。

エラー

EFAULT
sysinfo 構造体 へのポインターが不正である。

準拠

この関数は Linux 特有であり、移植を意図したプログラムでは 使用してはいけない。

Linux カーネルは 0.98.pl6 から sysinfo() システムコールを持っている。 Linux の libc は 5.3.5 より、glibc では 1.90 より sysinfo() ルーチンを含んでいる。

関連項目

proc(5)