OSDN Git Service

Import translated manuals from JM CVS Repository.
[linuxjm/jm.git] / manual / LDP_man-pages / draft / 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 .\" Japanese Version Copyright (c) 2008  Akihiro MOTOKI
24 .\"         all rights reserved.
25 .\" Translated 2008-08-10, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.05
26 .\" 
27 .\"WORD:        accounting      ¥¢¥«¥¦¥ó¥Æ¥£¥ó¥°
28 .\"
29 .TH ACCT 5 2008-06-15 "Linux" "Linux Programmer's Manual"
30 .\"O .SH NAME
31 .SH Ì¾Á°
32 .\"O acct \- process accounting file
33 acct \- ¥×¥í¥»¥¹¡¦¥¢¥«¥¦¥ó¥Æ¥£¥ó¥°¡¦¥Õ¥¡¥¤¥ë
34 .\"O .SH SYNOPSIS
35 .SH ½ñ¼°
36 .B #include <sys/acct.h>
37 .\"O .SH DESCRIPTION
38 .SH ÀâÌÀ
39 .\"O If the kernel is built with the process accounting option enabled
40 .\"O .RB ( CONFIG_BSD_PROCESS_ACCT ),
41 .\"O then calling
42 .\"O .BR acct (2)
43 .\"O starts process accounting, for example:
44 ¥«¡¼¥Í¥ë¤¬¥×¥í¥»¥¹¡¦¥¢¥«¥¦¥ó¥Æ¥£¥ó¥°¤Î¥ª¥×¥·¥ç¥ó
45 .RB ( CONFIG_BSD_PROCESS_ACCT )
46 ¤òÍ­¸ú¤Ë¤·¤ÆºîÀ®¤µ¤ì¤Æ¤¤¤ë¤È¡¢°Ê²¼¤Î¤è¤¦¤Ë
47 .BR acct (2)
48 ¤ò¸Æ¤Ó½Ð¤¹¤È¥×¥í¥»¥¹¡¦¥¢¥«¥¦¥ó¥Æ¥£¥ó¥°¤¬³«»Ï¤µ¤ì¤ë¡£
49
50 .in +4n
51  acct("/var/log/pacct");
52 .in
53
54 .\"O When process accounting is enabled, the kernel writes a record
55 .\"O to the accounting file as each process on the system terminates.
56 .\"O This record contains information about the terminated process,
57 .\"O and is defined in
58 .\"O .I <sys/acct.h>
59 .\"O as follows:
60 ¥×¥í¥»¥¹¡¦¥¢¥«¥¦¥ó¥Æ¥£¥ó¥°¤¬Í­¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤È¡¢¥«¡¼¥Í¥ë¤Ï
61 ¥·¥¹¥Æ¥à¾å¤Î³Æ¥×¥í¥»¥¹¤¬½ªÎ»¤¹¤ë¤¿¤Ó¤Ë¥¢¥«¥¦¥ó¥Æ¥£¥ó¥°¥Õ¥¡¥¤¥ë¤Ë
62 ¥ì¥³¡¼¥É¤ò½ñ¤­¹þ¤à¡£
63 ¤³¤Î¥ì¥³¡¼¥É¤Ï¡¢½ªÎ»¤·¤¿¥×¥í¥»¥¹¤Ë´Ø¤¹¤ë¾ðÊó¤òÊÝ»ý¤¹¤ë¤â¤Î¤Ç¡¢
64 .I <sys/acct.h>
65 ¤Ç°Ê²¼¤Î¤è¤¦¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë¡£
66
67 .in +4n
68 .nf
69 #define ACCT_COMM 16
70
71 typedef u_int16_t comp_t;
72
73 struct acct {
74     char ac_flag;           /* Accounting flags */
75     u_int16_t ac_uid;       /* Accounting user ID */
76     u_int16_t ac_gid;       /* Accounting group ID */
77     u_int16_t ac_tty;       /* Controlling terminal */
78     u_int32_t ac_btime;     /* Process creation time
79                                (seconds since the Epoch) */
80     comp_t    ac_utime;     /* User CPU time */
81     comp_t    ac_stime;     /* System CPU time */
82     comp_t    ac_etime;     /* Elapsed time */
83     comp_t    ac_mem;       /* Average memory usage (kB) */
84     comp_t    ac_io;        /* Characters transferred (unused) */
85     comp_t    ac_rw;        /* Blocks read or written (unused) */
86     comp_t    ac_minflt;    /* Minor page faults */
87     comp_t    ac_majflt;    /* Major page faults */
88     comp_t    ac_swaps;     /* Number of swaps (unused) */
89     u_int32_t ac_exitcode;  /* Process termination status
90                                (see wait(2)) */
91     char      ac_comm[ACCT_COMM+1];
92                             /* Command name (basename of last
93                                executed command; null-terminated) */
94     char      ac_pad[\fIX\fP];    /* padding bytes */
95 };
96
97 enum {          /* Bits that may be set in ac_flag field */
98     AFORK = 0x01,           /* Has executed fork, but no exec */
99     ASU   = 0x02,           /* Used superuser privileges */
100     ACORE = 0x08,           /* Dumped core */
101     AXSIG = 0x10            /* Killed by a signal */
102 };
103 .fi
104 .in
105 .PP
106 .\"O The
107 .\"O .I comp_t
108 .\"O data type is a floating-point value consisting of a 3-bit, base-8 exponent,
109 .\"O and a 13-bit mantissa.
110 .\"O A value,
111 .\"O .IR c ,
112 .\"O of this type can be converted to a (long) integer as follows:
113 ¥Ç¡¼¥¿·¿
114 .I comp_t
115 ¤ÏÉâÆ°¾®¿ôÅÀÃͤǡ¢3 ¥Ó¥Ã¥ÈÉý¤Î´ð¿ô¤¬ 8 ¤Î»Ø¿ôÉô¤È 13 ¥Ó¥Ã¥ÈÉý¤Î²¾¿ôÉô¤«¤é
116 ¹½À®¤µ¤ì¤ë¡£
117 .I comp_t
118 ·¿¤ÎÃÍ
119 .I c
120 ¤Ï°Ê²¼¤Î¤è¤¦¤Ë¤·¤Æ (long ·¿¤Î) À°¿ô¤ËÊÑ´¹¤Ç¤­¤ë¡£
121 .nf
122
123     v = (c & 0x1fff) << (((c >> 13) & 0x7) * 3);
124 .fi
125 .PP
126 .\"O The
127 .\"O .IR ac_utime ,
128 .\"O .IR ac_stime ,
129 .\"O and
130 .\"O .I ac_etime
131 .\"O fields measure time in "clock ticks"; divide these values by
132 .\"O .I sysconf(_SC_CLK_TCK)
133 .\"O to convert them to seconds.
134 ¥Õ¥£¡¼¥ë¥É
135 .IR ac_utime ,
136 .IR ac_stime ,
137 .I ac_etime
138 ¤Ï "clock ticks" Ã±°Ì¤Ç·×¬¤·¤¿»þ´Ö¤Ç¤¢¤ë¡£
139 ¤³¤ì¤é¤ÎÃͤò
140 .I sysconf(_SC_CLK_TCK)
141 ¤Ç³ä¤ë¤È¡¢ÉäËÊÑ´¹¤Ç¤­¤ë¡£
142 .\"O .SS Version 3 Accounting File Format
143 .SS ¥Ð¡¼¥¸¥ç¥ó 3 ¤Î¥¢¥«¥¦¥ó¥Æ¥£¥ó¥°¥Õ¥¡¥¤¥ë¤Î¥Õ¥©¡¼¥Þ¥Ã¥È
144 .\"O Since kernel 2.6.8,
145 .\"O an optional alternative version of the accounting file can be produced
146 .\"O if the
147 .\"O .B CONFIG_BSD_PROCESS_ACCT_V3
148 .\"O option is set when building the kernel.
149 .\"O With this option is set,
150 .\"O the records written to the accounting file contain additional fields,
151 .\"O and the width of
152 .\"O .I c_uid
153 .\"O and
154 .\"O .I ac_gid
155 .\"O fields is widened from 16 to 32 bits
156 .\"O (in line with the increased size of UID and GIDs in Linux 2.4 and later).
157 .\"O The records are defined as follows:
158 ¥«¡¼¥Í¥ë 2.6.8 °Ê¹ß¤Ç¤Ï¡¢
159 Ê̤ΥС¼¥¸¥ç¥ó¤Î¥¢¥«¥¦¥ó¥Æ¥£¥ó¥°¥Õ¥¡¥¤¥ë¤òÀ¸À®¤¹¤ë¤³¤È¤¬¤Ç¤­¡¢
160 ¤³¤ì¤ò»È¤¦¤Ë¤Ï¥«¡¼¥Í¥ë¹½ÃÛ»þ¤Ë
161 .B CONFIG_BSD_PROCESS_ACCT_V3
162 ¥ª¥×¥·¥ç¥ó¤¬Í­¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤ëɬÍפ¬¤¢¤ë¡£
163 ¤³¤Î¥ª¥×¥·¥ç¥ó¤¬ÀßÄꤵ¤ì¤ë¤È¡¢¥¢¥«¥¦¥ó¥Æ¥£¥ó¥°¥Õ¥¡¥¤¥ë¤Ë½ñ¤­¹þ¤Þ¤ì¤ë
164 ¥ì¥³¡¼¥É¤Ë¥Õ¥£¡¼¥ë¥É¤¬Äɲ䵤ì¤ë¡£
165 ¤Þ¤¿¡¢¥Õ¥£¡¼¥ë¥É
166 .I c_uid
167 ¤È
168 .I ac_gid
169 ¤ÎÉý¤¬ 16 ¥Ó¥Ã¥È¤«¤é 32 ¥Ó¥Ã¥È¤Ë³ÈÄ¥¤µ¤ì¤ë
170 (¤³¤ì¤Ï Linux 2.4 °Ê¹ß¤Ç UID ¤È GID ¤Î¥µ¥¤¥º¤¬Áý¤¨¤Æ¤¤¤ë¤Î¤Ë
171 Âбþ¤·¤¿¤â¤Î¤Ç¤¢¤ë)¡£
172 ¤³¤Î¥ì¥³¡¼¥É¤Ï°Ê²¼¤Î¤è¤¦¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë¡£
173
174 .in +4n
175 .nf
176 struct acct_v3 {
177     char      ac_flag;      /* Flags */
178     char      ac_version;   /* Always set to ACCT_VERSION (3) */
179     u_int16_t ac_tty;       /* Controlling terminal */
180     u_int32_t ac_exitcode;  /* Process termination status */
181     u_int32_t ac_uid;       /* Real user ID */
182     u_int32_t ac_gid;       /* Real group ID */
183     u_int32_t ac_pid;       /* Process ID */
184     u_int32_t ac_ppid;      /* Parent process ID */
185     u_int32_t ac_btime;     /* Process creation time */
186     float     ac_etime;     /* Elapsed time */
187     comp_t    ac_utime;     /* User CPU time */
188     comp_t    ac_stime;     /* System time */
189     comp_t    ac_mem;       /* Average memory usage (kB) */
190     comp_t    ac_io;        /* Characters transferred (unused) */
191     comp_t    ac_rw;        /* Blocks read or written
192                                (unused) */
193     comp_t    ac_minflt;    /* Minor page faults */
194     comp_t    ac_majflt;    /* Major page faults */
195     comp_t    ac_swaps;     /* Number of swaps (unused) */
196     char      ac_comm[ACCT_COMM]; /* Command name */
197 };
198
199 .fi
200 .in
201 .\"O .SH VERSIONS
202 .SH ¥Ð¡¼¥¸¥ç¥ó
203 .\"O The
204 .\"O .I acct_v3
205 .\"O structure is defined in glibc since version 2.6.
206 .I acct_v3
207 ¹½Â¤ÂΤϥС¼¥¸¥ç¥ó 2.6 °Ê¹ß¤Î glibc ¤ÇÄêµÁ¤µ¤ì¤Æ¤¤¤ë¡£
208 .\"O .SH CONFORMING TO
209 .SH ½àµò
210 .\"O Process accounting originated on BSD.
211 .\"O Although it is present on most systems, it is not standardized,
212 .\"O and the details vary somewhat between systems.
213 ¥×¥í¥»¥¹¥¢¥«¥¦¥ó¥Æ¥£¥ó¥°¤Ï BSD Í³Íè¤Ç¤¢¤ë¡£
214 ¤³¤Îµ¡Ç½¤Ï¤Û¤È¤ó¤É¤Î¥·¥¹¥Æ¥à¤Ë¸ºß¤¹¤ë¤¬¡¢É¸½à²½¤µ¤ì¤Æ¤ª¤é¤º¡¢
215 ¤½¤Î¾ÜºÙ¤Ï¥·¥¹¥Æ¥à¤Ë¤è¤ê¤¤¤¯¤é¤«°Û¤Ê¤ë¡£
216 .\"O .SH NOTES
217 .SH Ãí°Õ
218 .\"O Records in the accounting file are ordered by termination time of
219 .\"O the process.
220 ¥¢¥«¥¦¥ó¥Æ¥£¥ó¥°¥Õ¥¡¥¤¥ë¤Î¥ì¥³¡¼¥É¤Ï¡¢¥×¥í¥»¥¹¤Î½ªÎ»»þ¹ï¤Î½ç½ø¤È¤Ê¤ë¡£
221
222 .\"O In kernels up to and including 2.6.9,
223 .\"O a separate accounting record is written for each thread created using
224 .\"O the NPTL threading library;
225 .\"O since Linux 2.6.10,
226 .\"O a single accounting record is written for the entire process
227 .\"O on termination of the last thread in the process.
228 ¥Ð¡¼¥¸¥ç¥ó 2.6.9 °ÊÁ°¤Î¥«¡¼¥Í¥ë¤Ç¤Ï¡¢
229 NPTL ¥¹¥ì¥Ã¥É¥é¥¤¥Ö¥é¥ê¤ò»È¤Ã¤ÆºîÀ®¤µ¤ì¤¿¥¹¥ì¥Ã¥É¤Ç¤Ï
230 ¥¹¥ì¥Ã¥ÉËè¤ËÊÌ¡¹¤Î¥¢¥«¥¦¥ó¥Æ¥£¥ó¥°¥ì¥³¡¼¥É¤¬½ñ¤­¹þ¤Þ¤ì¤Æ¤¤¤¿¡£
231 Linux 2.6.10 °Ê¹ß¤Ç¤Ï¡¢¥×¥í¥»¥¹Æâ¤ÎºÇ¸å¤Î¥¹¥ì¥Ã¥É¤¬½ªÎ»¤¹¤ë¤È¡¢
232 ¥×¥í¥»¥¹Á´ÂΤˤĤ¤¤Æ¤Î¥¢¥«¥¦¥ó¥Æ¥£¥ó¥°¥ì¥³¡¼¥É¤¬°ì¤Ä¤À¤±½ñ¤­¹þ¤Þ¤ì¤ë¡£
233
234 .\"O The
235 .\"O .I proc/sys/kernel/acct
236 .\"O file, described in
237 .\"O .BR proc (5),
238 .\"O defines settings that control the behavior of process accounting
239 .\"O when disk space runs low.
240 .I proc/sys/kernel/acct
241 ¥Õ¥¡¥¤¥ë
242 .RB ( proc (5)
243 ¤ÇÀâÌÀ¤µ¤ì¤Æ¤¤¤ë) ¤Ï¡¢¥Ç¥£¥¹¥¯ÍÆÎ̤λĤ꤬¾¯¤Ê¤¯¤Ê¤Ã¤¿ºÝ¤Î
244 ¥×¥í¥»¥¹¡¦¥¢¥«¥¦¥ó¥Æ¥£¥ó¥°¤ÎÆ°ºî¤òÀ©¸æ¤¹¤ëÀßÄê¤òÊÝ»ý¤·¤Æ¤¤¤ë¡£
245 .\"O .SH SEE ALSO
246 .SH ´ØÏ¢¹àÌÜ
247 .BR lastcomm (1),
248 .BR acct (2),
249 .BR accton (8),
250 .BR sa (8)