Linux进程记账(psacct)是如何工作的?

3
我找到了很多关于 psacct 的文档,但它们只涉及使用方法而不涉及其工作原理。
问题
我真的想知道进程记账是如何工作的:
1. 系统的哪个部分记录有关进程的信息? 2. 它是如何工作的?
已完成
我在RHEL 6.5上安装了psacct。
1. 服务启动脚本实际上(/etc/init.d/psacct)调用以下内容: /sbin/accton $ACCTFILE 2. /sbin/accton 调用系统调用 acct() man acct
描述 acct()系统调用启用或禁用进程记账。如果使用现有文件名作为参数调用,则打开记账,并在每个终止的进程中将记录追加到文件名。NULL参数会导致记帐关闭。

我建议您使用您喜欢的互联网搜索引擎,使用“Linux进程记账”这些术语进行搜索,阅读至少前10个搜索结果的文档,然后再回来提出更具体的问题。 - user2845360
使用源代码,卢克 - mpez0
1个回答

2
你的问题的答案在Linux源文件中,具体在kernel/acct.c中。特别是在fill_ac函数中。
/*
 *  Write an accounting entry for an exiting process
 *
 *  The acct_process() call is the workhorse of the process
 *  accounting system. The struct acct is built here and then written
 *  into the accounting file. This function should only be called from
 *  do_exit() or when switching to a different output file.
 */

static void fill_ac(acct_t *ac)

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接