繁体   English   中英

Linux Process Accounting(psacct)如何工作?

[英]How does Linux Process Accounting (psacct) work?

我找到了很多关于psacct文档,但它们正在解决使用问题,而不是它的工作方式。

我真的想知道流程会计的工作原理:

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

  2. 它是如何工作的?

已经完成了

我在RHEL 6.5上安装了psacct。

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

    / sbin / accton $ ACCTFILE

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

男人的

描述acct()系统调用启用或禁用进程记帐。 如果使用现有文件的名称作为其参数进行调用,则会启用记帐,并在终止时将每个终止进程的记录附加到filename。 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)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM