gpt4 book ai didi

linux - Linux 进程记帐 (psacct) 是如何工作的?

转载 作者:太空狗 更新时间:2023-10-29 11:13:36 25 4
gpt4 key购买 nike

我找到了很多关于 psacct 的文档,但它们都在说明用法,而不是它是如何工作的。

问题

我真的很想知道流程会计是如何工作的:

  1. 系统的哪一部分记录有关进程的信息?

  2. 它是如何工作的?

已经完成

我在 RHEL 6.5 上安装了 psacct。

  1. 服务启动脚本 (/etc/init.d/psacct) 调用这个:

    /sbin/accton $ACCTFILE

  2. /sbin/accton调用系统调用acct()

男人帐户

描述 acct() 系统调用启用或禁用进程记帐。如果以现有文件的名称作为参数调用,accounting 是 打开,并且每个终止进程的记录在它终止时附加到文件名。 NULL 参数导致记帐 关闭。

最佳答案

您的问题的答案在 linux 源文件中 kernel/acct.c .特别是在 fill_ac function

/*
* 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)

关于linux - Linux 进程记帐 (psacct) 是如何工作的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29246631/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com