Wie kann ich PID- und PPID-Felder in psacct dump-acct aktivieren?

Wie kann ich PID- und PPID-Felder in psacct dump-acct aktivieren?

Ich verwende derzeit das psacct-Paket auf Centos, um die Abrechnung der von Benutzern ausgeführten Prozesse durchzuführen.

Die Infodatei1schlägt vor, dass es möglich ist, PID und PPID auszugeben, abhängig davon, welche Informationen Ihr Betriebssystem in seiner Struktur „acct“ bereitstellt.

pid und ppid sind auf meinem System in /usr/include/linux/acct.h aufgeführt:

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

Aber pid und ppid werden nicht ausgegeben, wenn ich dump-acct ausführe:

# 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

Ist es wahrscheinlich, dass mein Kernel diese Funktion nicht unterstützt oder dass meine psacct-Version sie nicht unterstützt?

Wie kann ich meinen Buchhaltungsprotokollen PID und PPID hinzufügen?

CentOS Version 5.6

Kernel 2.6.18-238.19.1.el5

psacct 6.3.2

Antwort1

Ich fand das gerade imÄnderungsprotokoll für das psacct RPM:

* Fri Nov 13 2009 Ivana Varekova <varekova(at)redhat.com> - 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

Es scheint also davon abzuhängen, welche Version Sie genau verwenden.

Antwort2

CentOS release 5.6
psacct 6.3.2

Das psacctmit CentOS 5.6 gelieferte Paket hat die Versionsnummer 44:

Name       : psacct
Arch       : x86_64
Version    : 6.3.2
Release    : 44.el5
Size       : 107 k
Repo       : installed
Summary    : Utilities for monitoring process activities.
License    : GPL
Description: The psacct package contains several utilities for monitoring process
           : activities, including ac, lastcomm, accton and sa. The ac command
           : displays statistics about how long users have been logged on. The
           : lastcomm command displays information about previous executed
           : commands. The accton command turns process accounting on or off. The
           : sa command summarizes information about previously executed
           : commands.

und wie @Ladadadada erwähnt hat, sind PID und PPID laut Änderungsprotokoll erst ab Version 6.3.2-56 verfügbar. Auf meinem CentOS 6 (psacct-6.3.2-63):

accton           |   0.0|   0.0|   1.0|    0|    0|3832.0|   16114    16111|Thu Nov 24 13:37:50 2011
touch            |   0.0|   0.0|   3.0|    0|    0|105088.0|   16115    16111|Thu Nov 24 13:37:50 2011
psacct           |   0.0|   0.0|   9.0|    0|    0|106304.0|   16111    16059|Thu Nov 24 13:37:50 2011
w                |   0.0|   0.0|   3.0|    0|    0|105280.0|   16116    16059|Thu Nov 24 13:37:52 2011

verwandte Informationen