How to configure maximum archive size and retention period for Performance Co-Pilot?

Solution Verified - Updated

Environment

  • Red Hat Enterprise Linux (RHEL) 6, 7, 8, 9 and 10
  • Performance Co-Pilot (PCP)
  • Using the pmlogger system service directly (rather than the deprecated pmmgr) to manage the logger.

Issue

  • How to configure maximum archive size and retention period for Performance Co-Pilot?
  • We would like to configure maximum log archive sizes and retention period for PCP in RHEL8, RHEL7 & RHEL6, can you please advise where and what configuration needs to be done?

Resolution

Log Retention

Log retention time can be changed with the -k or --discard option in the pmlogger daily script. On PCP version pcp-4.3.2 and later, the log management scripts are run under systemd timers and are tuned by editing/etc/sysconfig/pmlogger_timers and changing the PMLOGGER_DAILY_PARAMS variable.

For cron based log management on versions prior to pcp-4.3.2, edit /etc/cron.d/pcp-pmlogger and add or change variables, e.g.

10     0  *  *  *  pcp /usr/libexec/pcp/bin/pmlogger_daily -X xz -x 3 --discard 30

For version pcp-4.3.2 and later, edit /etc/sysconfig/pmlogger_timers and change the PMLOGGER_DAILY_PARAMS variable.

--discard 30 keeps logs for 30 days (default 14).

Log Compression

Log compression is controlled with the -x or --compress-after option in the pmlogger daily script, eg:

/etc/cron.d/pcp-pmlogger

10     0  *  *  *  pcp /usr/libexec/pcp/bin/pmlogger_daily -X xz -x 5

-x 5 sets compression after 5 days. Once again, for version pcp-4.3.2 and later, edit /etc/sysconfig/pmlogger_timers and change the PMLOGGER_DAILY_PARAMS variable instead of the cron tab entry.

It is strongly recommended to use the default compression options - PCP archive logs compress very well (~ 90%) and the PCP libraries and tools all support transparent decompression on replay. The default is -x 0, i.e. compress whenever a log volume is rolled.

Volume Size

The pmlogger individual volume file size rollover can be set with the -v option passed to the daemon, eg:

/etc/pcp/pmlogger/control.d/local

LOCALHOSTNAME   y   n   PCP_LOG_DIR/pmlogger/LOCALHOSTNAME      -r -T24h10m -c config.default -v 100Mb

-v 100Mb rolls into a new archive every 100MiB. The format is explained in man pmlogger.

Note this will not restrict the daemon to limit archive files to a particular size, it just configures at which size archives files will be rolled over/new archive files will be started.

Root Cause

  • The default time for which PCP retains logs is 14 days.
  • The default log compression is 0 days (i.e. whenever a log volume is rolled).

Diagnostic Steps

  • Log retention is the CULLAFTER variable.

  • Log compression is the COMPRESSAFTER variable.

  • Volume size is explained in pmlogger(1) and pmlogger_daily(1).

  • As of pcp-5.3 and later, root can execute systemctl start pmlogger_daily and with that manually trigger the cleanup/compression scripts which usually are executed shortly after midnight. These scripts are sourcing file /etc/sysconfig/pmlogger_timers. When pmlogger_daily is executed, notification about that appears in /var/log/messages, as per default config. By default, if verbosity is not set and no errors occur, the script is not generating a dedicated logfile. Verbosity can be set for example in setting PMLOGGER_DAILY_PARAMS="-k 20 -VVV" in /etc/sysconfig/pmlogger_timers, the logfile is then appearing as /var/log/pcp/pmlogger/pmlogger_daily.log.

  • The cleanup script pmlogger_daily can also be executed directly, options from the commandline can then be used instead of the options from /etc/sysconfig/pmlogger_timers. Example of direct execution:

    /usr/libexec/pcp/bin/pmlogger_daily --discard 3 -VVV -x 4 -k 7

Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.