Questo contenuto non è disponibile nella lingua selezionata.

Chapter 6. Logging performance data with pmlogger


With the PCP tool you can log the performance metric values and replay them later. You can use this data to perform retrospective performance analysis. Using the pmlogger tool, you can:

  • Create the archived logs of selected metrics on the system
  • Specify which metrics are recorded on the system and how often

6.1. Modifying the pmlogger configuration file with pmlogconf

When the pmlogger service is running, PCP logs a default set of metrics on the host. Use the pmlogconf utility to check the default configuration. If the pmlogger configuration file does not exist, pmlogconf creates it with a default metric values.

Prerequisites

Procedure

  1. Create or modify the pmlogger configuration file:

    # pmlogconf -r /var/lib/pcp/config/pmlogger/config.default
  2. Follow pmlogconf prompts to enable or disable groups of related performance metrics and to control the logging interval for each enabled group. For example,

    # pmlogconf -r /var/lib/pcp/config/pmlogger/config.default
    Group: per logical block device activity
    Log this group? [y]
    Logging interval? [default]

6.2. Configuring pmlogger manually

You can edit the pmlogger configuration file manually to create a tailored logging configuration with specific metrics and given intervals. The default pmlogger configuration file is /var/lib/pcp/config/pmlogger/config.default. The configuration file specifies which metrics are logged by the primary logging instance.

In manual configuration, you can:

  • Record metrics which are not listed in the automatic configuration.
  • Choose custom logging frequencies.
  • Add PMDA with the application metrics.

Prerequisites

Procedure

  • Open and edit the /var/lib/pcp/config/pmlogger/config.default file to add specific metrics:

    # It is safe to make additions from here on ...
    #
    log mandatory on every 5 seconds {
        xfs.write
        xfs.write_bytes
        xfs.read
        xfs.read_bytes
    }
    log mandatory on every 10 seconds {
        xfs.allocs
        xfs.block_map
        xfs.transactions
        xfs.log
    }
    [access]
    disallow * : all;
    allow localhost : enquire;

6.3. Enabling the pmlogger service

The pmlogger service must be started and enabled to log the metric values on the local machine.

Prerequisites

Procedure

  • Start and enable the pmlogger service:

    # systemctl start pmlogger
    # systemctl enable pmlogger

Verification

  • Verify that the pmlogger service is enabled:

    # pcp
     platform: Linux arm10.local 6.12.0-55.13.1.el10_0.aarch64 #1 SMP PREEMPT_DYNAMIC Mon May 19 07:29:57 UTC 2025 aarch64
     hardware: 4 cpus, 1 disk, 1 node, 3579MB RAM
     timezone: JST-9
     services: pmcd
         pmcd: Version 6.3.7-1, 12 agents, 6 clients
         pmda: root pmcd proc pmproxy xfs linux nfsclient mmv kvm jbd2
               dm openmetrics
     pmlogger: primary logger: /var/log/pcp/pmlogger/arm10.local/20250529.15.49
         pmie: primary engine: /var/log/pcp/pmie/arm10.local/pmie.log

    For more information, see the /var/lib/pcp/config/pmlogger/config.default file.

6.4. Setting up a client system for metrics collection

You can configure a client system to enable a central server to collect performance metrics from clients running PCP.

Prerequisites

Procedure

  1. Install the pcp-system-tools package:

    # dnf install pcp-system-tools
  2. Configure an IP address for pmcd:

    # echo "-i 192.168.4.62" >>/etc/pcp/pmcd/pmcd.options

    Replace 192.168.4.62 with the IP address, the client should listen on. By default, pmcd is listening on the localhost.

  3. Configure the firewall to add the public zone permanently:

    # firewall-cmd --permanent --zone=public --add-port=44321/tcp
    success
    # firewall-cmd --reload
    success
  4. Set an SELinux boolean:

    # setsebool -P pcp_bind_all_unreserved_ports on
  5. Enable the pmcd and pmlogger services:

    # systemctl enable pmcd pmlogger
    # systemctl restart pmcd pmlogger

Verification

  • Verify that the pmcd is correctly listening on the configured IP address:

    # ss -tlp | grep 44321
    LISTEN   0   5     127.0.0.1:44321   0.0.0.0:*   users:(("pmcd",pid=151595,fd=6))
    LISTEN   0   5  192.168.4.62:44321   0.0.0.0:*   users:(("pmcd",pid=151595,fd=0))
    LISTEN   0   5         [::1]:44321      [::]:*   users:(("pmcd",pid=151595,fd=7))

6.5. Setting up a central server to collect data

You can create a central server to collect metrics from clients running PCP.

Prerequisites

Procedure

  1. Install the pcp-system-tools package:

    # dnf install pcp-system-tools
  2. Create the /etc/pcp/pmlogger/control.d/remote file with the following content:

    # DO NOT REMOVE OR EDIT THE FOLLOWING LINE
    $version=1.1
    192.168.4.13 n n PCP_ARCHIVE_DIR/rhel7u4a -r -T24h10m -c config.rhel7u4a
    192.168.4.14 n n PCP_ARCHIVE_DIR/rhel6u10a -r -T24h10m -c config.rhel6u10a
    192.168.4.62 n n PCP_ARCHIVE_DIR/rhel8u1a -r -T24h10m -c config.rhel8u1a

    Replace 192.168.4.13, 192.168.4.14 and 192.168.4.62 with the client IP addresses.

  3. Enable the pmcd and pmlogger services:

    # systemctl enable pmcd pmlogger
    # systemctl restart pmcd pmlogger

Verification

  • Verify that you can access the latest archive file from each directory:

    # for i in /var/log/pcp/pmlogger/rhel*/*.0; do pmdumplog -L $i; done
    Log Label (Log Format Version 2)
    Performance metrics from host rhel6u10a.local
      commencing Mon Nov 25 21:55:04.851 2019
      ending     Mon Nov 25 22:06:04.874 2019
    Archive timezone: JST-9
    PID for pmlogger: 24002
    Log Label (Log Format Version 2)
    Performance metrics from host rhel7u4a
      commencing Tue Nov 26 06:49:24.954 2019
      ending     Tue Nov 26 07:06:24.979 2019
    Archive timezone: CET-1
    PID for pmlogger: 10941
    [..]

    The archive files from the /var/log/pcp/pmlogger/ directory can be used for further analysis and graphing.

6.6. Systemd units and pmlogger

The pmlogger deployments, whether local or a remote farm, include several associated systemd service and timer units. These units monitor pmlogger instances, restart failed processes, and manage archives through tasks like file compression.

The checking and housekeeping services typically deployed by pmlogger are:

pmlogger_daily.service
Runs daily, soon after midnight by default, to aggregate, compress, and rotate one or more sets of PCP archives. Also culls archives older than the limit, 2 weeks by default. Triggered by the pmlogger_daily.timer unit, which is required by the pmlogger.service unit.
pmlogger_check
Performs half-hourly checks that pmlogger instances are running. Restarts any missing instances and performs any required compression tasks. Triggered by the pmlogger_check.timer unit, which is required by the pmlogger.service unit.
pmlogger_farm_check
Checks the status of all configured pmlogger instances. Restarts any missing instances. Migrates all non-primary instances to the pmlogger_farm service. Triggered by the pmlogger_farm_check.timer, which is required by the pmlogger_farm.service unit that is itself required by the pmlogger.service unit.

These services are managed through a series of positive dependencies, meaning that they are all enabled upon activating the primary pmlogger instance. Note that while pmlogger_daily.service is disabled by default, pmlogger_daily.timer being active through the dependency with pmlogger.service will trigger pmlogger_daily.service to run.

pmlogger_daily is also integrated with pmlogrewrite for automatically rewriting archives before merging. This helps to ensure metadata consistency amid changing production environments and PMDAs. For example, updating pmcd during logging can change metric semantics, creating new archives incompatible with previously recorded data. For more information, see the pmlogrewrite(1) man page on your system.

6.7. Managing systemd services triggered by pmlogger

You can create an automated custom archive management system for data collected by your pmlogger instances by using the control files.

Note

The primary pmlogger instance must be running on the same host as the pmcd it connects to. You do not need to configure a primary instance. If a central host collects data from several pmlogger instances connected to pmcd instances running on remote hosts, a primary instance might not be required.

Procedure

  • Do one of the following:

    • For the primary pmlogger instance, use /etc/pcp/pmlogger/control.d/local
    • For the remote hosts, use /etc/pcp/pmlogger/control.d/remote

      Replace remote with the file name that you want to use.

      The file should contain one line for each host to be logged. The default format of the primary logger instance that is automatically created looks similar to:

      # === LOGGER CONTROL SPECIFICATIONS ===
      #
      #Host   	 P?  S?    directory   		 args
      # local primary logger
      LOCALHOSTNAME    y   n    PCP_ARCHIVE_DIR/LOCALHOSTNAME    -r -T24h10m -c config.default -v 100Mb

      Where the fields are:

      Host
      The name of the host to be logged.
      P?
      Stands for “Primary?". This field indicates if the host is the primary logger instance, y, or not, n. Only one primary logger is permitted. It must run on the same host as its connected pmcd instance.
      S?
      Stands for “Socks?". This field indicates if this logger instance needs to use the SOCKS protocol to connect to pmcd through a firewall, y, or not, n.
      directory
      All archives associated with this line are created in this directory.
      args
      Arguments passed to pmlogger. The default values for the args field are:
      -r
      Report the archive sizes and growth rate.
      T24h10m
      Specifies when to end logging for each day. This is typically the time when pmlogger_daily.service runs. The default value of 24h10m indicates that logging should end 24 hours and 10 minutes after it begins, at the latest.
      -c config.default
      Specifies which configuration file to use. This defines what metrics to record.
      -v 100Mb
      Specifies the size at which point one data volume is filled and another is created. After it switches to the new archive, the previously recorded one will be compressed by either pmlogger_daily or pmlogger_check.

6.8. Replaying the PCP log archives with pmrep

After recording the metric data, you can replay the PCP log archives. To export the logs to text files and import them into spreadsheets, use PCP utilities such as pcp2csv, pcp2xml, pmrep or pmlogsummary. By using the pmrep tool, you can:

  • View the log files.
  • Parse the selected PCP log archive and export the values into an ASCII table.
  • Extract the entire archive log or only select metric values from the log by specifying individual metrics on the command line.

Prerequisites

Procedure

  • Display the data on the metric:

    $ pmrep --start @3:00am --archive 20211128 --interval 5seconds --samples 10 --output csv disk.dev.write
    Time,"disk.dev.write-sda","disk.dev.write-sdb"
    2021-11-28 03:00:00,,
    2021-11-28 03:00:05,4.000,5.200
    2021-11-28 03:00:10,1.600,7.600
    2021-11-28 03:00:15,0.800,7.100
    2021-11-28 03:00:20,16.600,8.400
    2021-11-28 03:00:25,21.400,7.200
    2021-11-28 03:00:30,21.200,6.800
    2021-11-28 03:00:35,21.000,27.600
    2021-11-28 03:00:40,12.400,33.800
    2021-11-28 03:00:45,9.800,20.600

    The example displays the data on the disk.dev.write metric collected in an archive at a 5 second interval in comma-separated-value format. Replace 20211128 in this example with a filename containing the pmlogger archive you want to display data for.

Red Hat logoGithubredditYoutubeTwitter

Formazione

Prova, acquista e vendi

Community

Informazioni sulla documentazione di Red Hat

Aiutiamo gli utenti Red Hat a innovarsi e raggiungere i propri obiettivi con i nostri prodotti e servizi grazie a contenuti di cui possono fidarsi. Esplora i nostri ultimi aggiornamenti.

Rendiamo l’open source più inclusivo

Red Hat si impegna a sostituire il linguaggio problematico nel codice, nella documentazione e nelle proprietà web. Per maggiori dettagli, visita il Blog di Red Hat.

Informazioni su Red Hat

Forniamo soluzioni consolidate che rendono più semplice per le aziende lavorare su piattaforme e ambienti diversi, dal datacenter centrale all'edge della rete.

Theme

© 2026 Red Hat
Torna in cima