OSDN Git Service

(split) LDP: Release pages for LDP v3.39.
[linuxjm/LDP_man-pages.git] / release / man5 / acct.5
1 .\" Copyright (C) 2008, Michael Kerrisk <mtk.manpages@gmail.com>
2 .\"
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
6 .\"
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
11 .\"
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein.  The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\"
23 .\"*******************************************************************
24 .\"
25 .\" This file was generated with po4a. Translate the source file.
26 .\"
27 .\"*******************************************************************
28 .TH ACCT 5 2008\-06\-15 Linux "Linux Programmer's Manual"
29 .SH 名前
30 acct \- プロセス・アカウンティング・ファイル
31 .SH 書式
32 \fB#include <sys/acct.h>\fP
33 .SH 説明
34 カーネルがプロセス・アカウンティングのオプション (\fBCONFIG_BSD_PROCESS_ACCT\fP)  を有効にして作成されていると、以下のように
35 \fBacct\fP(2)  を呼び出すとプロセス・アカウンティングが開始される。
36
37 .in +4n
38 acct("/var/log/pacct");
39 .in
40
41 プロセス・アカウンティングが有効になっていると、カーネルは システム上の各プロセスが終了するたびにアカウンティングファイルに レコードを書き込む。
42 このレコードは、終了したプロセスに関する情報を保持するもので、 \fI<sys/acct.h>\fP で以下のように定義されている。
43
44 .in +4n
45 .nf
46 #define ACCT_COMM 16
47
48 typedef u_int16_t comp_t;
49
50 struct acct {
51     char ac_flag;           /* Accounting flags */
52     u_int16_t ac_uid;       /* Accounting user ID */
53     u_int16_t ac_gid;       /* Accounting group ID */
54     u_int16_t ac_tty;       /* Controlling terminal */
55     u_int32_t ac_btime;     /* Process creation time
56                                (seconds since the Epoch) */
57     comp_t    ac_utime;     /* User CPU time */
58     comp_t    ac_stime;     /* System CPU time */
59     comp_t    ac_etime;     /* Elapsed time */
60     comp_t    ac_mem;       /* Average memory usage (kB) */
61     comp_t    ac_io;        /* Characters transferred (unused) */
62     comp_t    ac_rw;        /* Blocks read or written (unused) */
63     comp_t    ac_minflt;    /* Minor page faults */
64     comp_t    ac_majflt;    /* Major page faults */
65     comp_t    ac_swaps;     /* Number of swaps (unused) */
66     u_int32_t ac_exitcode;  /* Process termination status
67                                (see wait(2)) */
68     char      ac_comm[ACCT_COMM+1];
69                             /* Command name (basename of last
70                                executed command; null\-terminated) */
71     char      ac_pad[\fIX\fP];    /* padding bytes */
72 };
73
74 enum {          /* Bits that may be set in ac_flag field */
75     AFORK = 0x01,           /* Has executed fork, but no exec */
76     ASU   = 0x02,           /* Used superuser privileges */
77     ACORE = 0x08,           /* Dumped core */
78     AXSIG = 0x10            /* Killed by a signal */
79 };
80 .fi
81 .in
82 .PP
83 データ型 \fIcomp_t\fP は浮動小数点値で、3 ビット幅の基数が 8 の指数部と 13 ビット幅の仮数部から 構成される。 \fIcomp_t\fP
84 型の値 \fIc\fP は以下のようにして (long 型の) 整数に変換できる。
85 .nf
86
87     v = (c & 0x1fff) << (((c >> 13) & 0x7) * 3);
88 .fi
89 .PP
90 フィールド \fIac_utime\fP, \fIac_stime\fP, \fIac_etime\fP は "clock ticks" 単位で計測した時間である。
91 これらの値を \fIsysconf(_SC_CLK_TCK)\fP で割ると、秒に変換できる。
92 .SS "バージョン 3 のアカウンティングファイルのフォーマット"
93 カーネル 2.6.8 以降では、 別のバージョンのアカウンティングファイルを生成することができ、 これを使うにはカーネル構築時に
94 \fBCONFIG_BSD_PROCESS_ACCT_V3\fP オプションが有効になっている必要がある。
95 このオプションが設定されると、アカウンティングファイルに書き込まれる レコードにフィールドが追加される。 また、フィールド \fIc_uid\fP と
96 \fIac_gid\fP の幅が 16 ビットから 32 ビットに拡張される (これは Linux 2.4 以降で UID と GID
97 のサイズが増えているのに 対応したものである)。 このレコードは以下のように定義されている。
98
99 .in +4n
100 .nf
101 struct acct_v3 {
102     char      ac_flag;      /* Flags */
103     char      ac_version;   /* Always set to ACCT_VERSION (3) */
104     u_int16_t ac_tty;       /* Controlling terminal */
105     u_int32_t ac_exitcode;  /* Process termination status */
106     u_int32_t ac_uid;       /* Real user ID */
107     u_int32_t ac_gid;       /* Real group ID */
108     u_int32_t ac_pid;       /* Process ID */
109     u_int32_t ac_ppid;      /* Parent process ID */
110     u_int32_t ac_btime;     /* Process creation time */
111     float     ac_etime;     /* Elapsed time */
112     comp_t    ac_utime;     /* User CPU time */
113     comp_t    ac_stime;     /* System time */
114     comp_t    ac_mem;       /* Average memory usage (kB) */
115     comp_t    ac_io;        /* Characters transferred (unused) */
116     comp_t    ac_rw;        /* Blocks read or written
117                                (unused) */
118     comp_t    ac_minflt;    /* Minor page faults */
119     comp_t    ac_majflt;    /* Major page faults */
120     comp_t    ac_swaps;     /* Number of swaps (unused) */
121     char      ac_comm[ACCT_COMM]; /* Command name */
122 };
123
124 .fi
125 .in
126 .SH バージョン
127 \fIacct_v3\fP 構造体はバージョン 2.6 以降の glibc で定義されている。
128 .SH 準拠
129 プロセスアカウンティングは BSD 由来である。 この機能はほとんどのシステムに存在するが、標準化されておらず、
130 その詳細はシステムによりいくらか異なる。
131 .SH 注意
132 アカウンティングファイルのレコードは、プロセスの終了時刻の順序となる。
133
134 バージョン 2.6.9 以前のカーネルでは、 NPTL スレッドライブラリを使って作成されたスレッドでは
135 スレッド毎に別々のアカウンティングレコードが書き込まれていた。 Linux 2.6.10 以降では、プロセス内の最後のスレッドが終了すると、
136 プロセス全体についてのアカウンティングレコードが一つだけ書き込まれる。
137
138 \fIproc/sys/kernel/acct\fP ファイル (\fBproc\fP(5)  で説明されている) は、ディスク容量の残りが少なくなった際の
139 プロセス・アカウンティングの動作を制御する設定を保持している。
140 .SH 関連項目
141 \fBlastcomm\fP(1), \fBacct\fP(2), \fBaccton\fP(8), \fBsa\fP(8)