1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
|
.\" Copyright (C) 2008, Michael Kerrisk <mtk.manpages@gmail.com>
.\"
.\" 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.
.\"
.\" Japanese Version Copyright (c) 2008 Akihiro MOTOKI
.\" all rights reserved.
.\" Translated 2008-08-10, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.05
.\"
.\"WORD: accounting ƥ
.\"
.TH ACCT 5 2008-06-15 "Linux" "Linux Programmer's Manual"
.SH ̾
acct \- ץƥե
.SH
.B #include <sys/acct.h>
.SH
ͥ뤬ץƥΥץ
.RB ( CONFIG_BSD_PROCESS_ACCT )
ͭˤƺƤȡʲΤ褦
.BR acct (2)
ƤӽФȥץƥϤ롣
.in +4n
acct("/var/log/pacct");
.in
ץƥͭˤʤäƤȡͥ
ƥγƥץλ뤿Ӥ˥ƥե
쥳ɤࡣ
Υ쥳ɤϡλץ˴ؤݻΤǡ
.I <sys/acct.h>
ǰʲΤ褦Ƥ롣
.in +4n
.nf
#define ACCT_COMM 16
typedef u_int16_t comp_t;
struct acct {
char ac_flag; /* Accounting flags */
u_int16_t ac_uid; /* Accounting user ID */
u_int16_t ac_gid; /* Accounting group ID */
u_int16_t ac_tty; /* Controlling terminal */
u_int32_t ac_btime; /* Process creation time
(seconds since the Epoch) */
comp_t ac_utime; /* User CPU time */
comp_t ac_stime; /* System CPU time */
comp_t ac_etime; /* Elapsed time */
comp_t ac_mem; /* Average memory usage (kB) */
comp_t ac_io; /* Characters transferred (unused) */
comp_t ac_rw; /* Blocks read or written (unused) */
comp_t ac_minflt; /* Minor page faults */
comp_t ac_majflt; /* Major page faults */
comp_t ac_swaps; /* Number of swaps (unused) */
u_int32_t ac_exitcode; /* Process termination status
(see wait(2)) */
char ac_comm[ACCT_COMM+1];
/* Command name (basename of last
executed command; null-terminated) */
char ac_pad[\fIX\fP]; /* padding bytes */
};
enum { /* Bits that may be set in ac_flag field */
AFORK = 0x01, /* Has executed fork, but no exec */
ASU = 0x02, /* Used superuser privileges */
ACORE = 0x08, /* Dumped core */
AXSIG = 0x10 /* Killed by a signal */
};
.fi
.in
.PP
ǡ
.I comp_t
ưͤǡ3 ӥåδ 8 λؿ 13 ӥåβ
롣
.I comp_t
.I c
ϰʲΤ褦ˤ (long ) ѴǤ롣
.nf
v = (c & 0x1fff) << (((c >> 13) & 0x7) * 3);
.fi
.PP
ե
.IR ac_utime ,
.IR ac_stime ,
.I ac_etime
"clock ticks" ñ̤Ƿ¬֤Ǥ롣
ͤ
.I sysconf(_SC_CLK_TCK)
dzȡäѴǤ롣
.SS С 3 ΥƥեΥեޥå
ͥ 2.6.8 ʹߤǤϡ
̤ΥСΥƥե뤳ȤǤ
Ȥˤϥͥ빽ۻ
.B CONFIG_BSD_PROCESS_ACCT_V3
ץͭˤʤäƤɬפ롣
Υץꤵȡƥե˽ޤ
쥳ɤ˥եɤɲä롣
ޤե
.I c_uid
.I ac_gid
16 ӥåȤ 32 ӥåȤ˳ĥ
( Linux 2.4 ʹߤ UID GID ΥƤΤ
бΤǤ)
Υ쥳ɤϰʲΤ褦Ƥ롣
.in +4n
.nf
struct acct_v3 {
char ac_flag; /* Flags */
char ac_version; /* Always set to ACCT_VERSION (3) */
u_int16_t ac_tty; /* Controlling terminal */
u_int32_t ac_exitcode; /* Process termination status */
u_int32_t ac_uid; /* Real user ID */
u_int32_t ac_gid; /* Real group ID */
u_int32_t ac_pid; /* Process ID */
u_int32_t ac_ppid; /* Parent process ID */
u_int32_t ac_btime; /* Process creation time */
float ac_etime; /* Elapsed time */
comp_t ac_utime; /* User CPU time */
comp_t ac_stime; /* System time */
comp_t ac_mem; /* Average memory usage (kB) */
comp_t ac_io; /* Characters transferred (unused) */
comp_t ac_rw; /* Blocks read or written
(unused) */
comp_t ac_minflt; /* Minor page faults */
comp_t ac_majflt; /* Major page faults */
comp_t ac_swaps; /* Number of swaps (unused) */
char ac_comm[ACCT_COMM]; /* Command name */
};
.fi
.in
.SH С
.I acct_v3
¤ΤϥС 2.6 ʹߤ glibc Ƥ롣
.SH
ץƥ BSD ͳǤ롣
εǽϤۤȤɤΥƥ¸ߤ뤬ɸಽƤ餺
ξܺ٤ϥƥˤꤤ餫ۤʤ롣
.SH
ƥեΥ쥳ɤϡץνλνȤʤ롣
С 2.6.9 ΥͥǤϡ
NPTL åɥ饤֥Ȥäƺ줿åɤǤ
å̡Υƥ쥳ɤޤƤ
Linux 2.6.10 ʹߤǤϡץκǸΥåɤλȡ
ץΤˤĤƤΥƥ쥳ɤĤޤ롣
.I proc/sys/kernel/acct
ե
.RB ( proc (5)
Ƥ) ϡǥ̤λĤ꤬ʤʤäݤ
ץƥư椹ݻƤ롣
.SH Ϣ
.BR lastcomm (1),
.BR acct (2),
.BR accton (8),
.BR sa (8)
|