other versions
other languages
other sections
| ACCT(5) | Linux Programmer's Manual | ACCT(5) |
名前¶
acct - プロセス・アカウンティング・ファイル書式¶
#include <sys/acct.h>説明¶
カーネルがプロセス・アカウンティングのオプション ( CONFIG_BSD_PROCESS_ACCT) を有効にして作成されていると、以下のように acct(2) を呼び出すとプロセス・アカウンティングが開始される。acct("/var/log/pacct");
#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[ X]; /* 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 */
};
データ型 comp_t は浮動小数点値で、3 ビット幅の基数が 8 の指数部と 13 ビット幅の仮数部から 構成される。 comp_t 型の値 c は以下のようにして (long 型の) 整数に変換できる。
v = (c & 0x1fff) << (((c >> 13) & 0x7) * 3);
フィールド ac_utime, ac_stime,
ac_etime は "clock ticks"
単位で計測した時間である。
これらの値を sysconf(_SC_CLK_TCK)
で割ると、秒に変換できる。
バージョン 3 のアカウンティングファイルのフォーマット¶
カーネル 2.6.8 以降では、 別のバージョンのアカウンティングファイルを生成することができ、 これを使うにはカーネル構築時に CONFIG_BSD_PROCESS_ACCT_V3 オプションが有効になっている必要がある。 このオプションが設定されると、アカウンティングファイルに書き込まれる レコードにフィールドが追加される。 また、フィールド c_uid と ac_gid の幅が 16 ビットから 32 ビットに拡張される (これは Linux 2.4 以降で UID と GID のサイズが増えているのに 対応したものである)。 このレコードは以下のように定義されている。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 */
};
バージョン¶
acct_v3 構造体はバージョン 2.6 以降の glibc で定義されている。準拠¶
プロセスアカウンティングは BSD 由来である。 この機能はほとんどのシステムに存在するが、標準化されておらず、 その詳細はシステムによりいくらか異なる。注意¶
アカウンティングファイルのレコードは、プロセスの終了時刻の順序となる。関連項目¶
lastcomm(1), acct(2), accton(8), sa(8)この文書について¶
この man ページは Linux man-pages プロジェクトのリリース 3.41 の一部 である。プロジェクトの説明とバグ報告に関する情報は http://www.kernel.org/doc/man-pages/ に書かれている。| 2008-06-15 | Linux |