簡體   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