OSDN Git Service

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