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
Answer
I just found this in the changelog for the psacct RPM:
* Fri Nov 13 2009 Ivana Varekova - 6.3.2-56
- fix the psacct to deal with all acct types and
if it is possible and wanted then add the possibility
to display the pid and ppid number
So it looks like it depends in exactly which release you are using.
No comments:
Post a Comment