How can I enable pid and ppid fields in psacct dump-acct?

Posted by annavt on Server Fault See other posts from Server Fault or by annavt
Published on 2011-11-24T17:45:34Z Indexed on 2011/11/24 17:58 UTC
Read the original article Hit count: 317

Filed under:
|

I am currently using the psacct package on Centos to perform accounting on processes run by users.

The info file1 suggests that it is possible to output pid and ppid depending on what information your operating system provides in it's struct acct.

pid and ppid are listed in /usr/include/linux/acct.h on my system:

struct acct_v3
{
        char            ac_flag;                /* Flags */
        char            ac_version;             /* Always set to ACCT_VERSION */
        __u16           ac_tty;                 /* Control Terminal */
        __u32           ac_exitcode;            /* Exitcode */
        __u32           ac_uid;                 /* Real User ID */
        __u32           ac_gid;                 /* Real Group ID */
        __u32           ac_pid;                 /* Process ID */
        __u32           ac_ppid;                /* Parent Process ID */
...

But pid and ppid are not output when I run dump-acct:

# dump-acct /var/account/pacct.1 | tail
awk              |   0.0|   0.0|  81.0|    0|    0|8792.0|Thu Nov 24 04:03:04 2011
tmpwatch         |   0.0|   0.0|   1.0|    0|    0|3816.0|Thu Nov 24 04:03:04 2011
cups             |   0.0|   0.0|   4.0|    0|    0|8728.0|Thu Nov 24 04:03:04 2011
awk              |   0.0|   0.0|   4.0|    0|    0|8792.0|Thu Nov 24 04:03:04 2011
runlevel         |   0.0|   0.0|   0.0|    0|    0|3804.0|Thu Nov 24 04:03:04 2011
chkconfig        |   0.0|   0.0|   0.0|    0|    0|3840.0|Thu Nov 24 04:03:04 2011
inn-cron-expire  |   0.0|   0.0|   0.0|    0|    0|8728.0|Thu Nov 24 04:03:04 2011
awk              |   0.0|   0.0|   0.0|    0|    0|8792.0|Thu Nov 24 04:03:04 2011
gzip             |   5.0|   0.0|   9.0|    0|    0|4044.0|Thu Nov 24 04:03:04 2011
accton           |   0.0|   0.0|   1.0|    0|    0|   0.0|Thu Nov 24 04:03:04 2011

Is it likely that there is no support in my kernel for this feature or that my psacct version does not support this?

How can I add pid and ppid to my accounting logs?

CentOS release 5.6

Kernel 2.6.18-238.19.1.el5

psacct 6.3.2

Thanks in advance Anna

© Server Fault or respective owner

Related posts about pid

Related posts about accounting