Este contenido no está disponible en el idioma seleccionado.
Chapter 8. Logging performance data with pmlogger
With the PCP tool you can log the performance metric values and replay them later. This allows you to perform a 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
8.1. Modifying the pmlogger configuration file with pmlogconf Copiar enlaceEnlace copiado en el portapapeles!
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
- PCP is installed. For more information, see Installing and enabling PCP.
Procedure
Create or modify the
pmloggerconfiguration file:pmlogconf -r /var/lib/pcp/config/pmlogger/config.default
# pmlogconf -r /var/lib/pcp/config/pmlogger/config.defaultCopy to Clipboard Copied! Toggle word wrap Toggle overflow -
Follow
pmlogconfprompts to enable or disable groups of related performance metrics and to control the logging interval for each enabled group.
8.2. Editing the pmlogger configuration file manually Copiar enlaceEnlace copiado en el portapapeles!
To create a tailored logging configuration with specific metrics and given intervals, edit the pmlogger configuration file manually. 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
- PCP is installed. For more information, see Installing and enabling PCP.
Procedure
Open and edit the
/var/lib/pcp/config/pmlogger/config.defaultfile to add specific metrics:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
8.3. Enabling the pmlogger service Copiar enlaceEnlace copiado en el portapapeles!
The pmlogger service must be started and enabled to log the metric values on the local machine.
This procedure describes how to enable the pmlogger service.
Prerequisites
- PCP is installed. For more information, see Installing and enabling PCP.
Procedure
Start and enable the
pmloggerservice:systemctl start pmlogger systemctl enable pmlogger
# systemctl start pmlogger # systemctl enable pmloggerCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Verify if the
pmloggerservice is enabled:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
8.4. Setting up a client system for metrics collection Copiar enlaceEnlace copiado en el portapapeles!
This procedure describes how to set up a client system so that a central server can collect metrics from clients running PCP.
Prerequisites
- PCP is installed. For more information, see Installing and enabling PCP.
Procedure
Install the
pcp-system-toolspackage:dnf install pcp-system-tools
# dnf install pcp-system-toolsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Configure an IP address for
pmcd:echo "-i 192.168.4.62" >>/etc/pcp/pmcd/pmcd.options
# echo "-i 192.168.4.62" >>/etc/pcp/pmcd/pmcd.optionsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Replace 192.168.4.62 with the IP address, the client should listen on.
By default,
pmcdis listening on the localhost.Configure the firewall to add the public
zonepermanently:firewall-cmd --permanent --zone=public --add-port=44321/tcp firewall-cmd --reload
# firewall-cmd --permanent --zone=public --add-port=44321/tcp success # firewall-cmd --reload successCopy to Clipboard Copied! Toggle word wrap Toggle overflow Set an SELinux boolean:
setsebool -P pcp_bind_all_unreserved_ports on
# setsebool -P pcp_bind_all_unreserved_ports onCopy to Clipboard Copied! Toggle word wrap Toggle overflow Enable the
pmcdandpmloggerservices:systemctl enable pmcd pmlogger systemctl restart pmcd pmlogger
# systemctl enable pmcd pmlogger # systemctl restart pmcd pmloggerCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Verify if the
pmcdis correctly listening on the configured IP address:ss -tlp | grep 44321
# 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))Copy to Clipboard Copied! Toggle word wrap Toggle overflow
8.5. Setting up a central server to collect data Copiar enlaceEnlace copiado en el portapapeles!
This procedure describes how to create a central server to collect metrics from clients running PCP.
Prerequisites
- PCP is installed. For more information, see Installing and enabling PCP.
- Client is configured for metrics collection. For more information, see Setting up a client system for metrics collection.
Procedure
Install the
pcp-system-toolspackage:dnf install pcp-system-tools
# dnf install pcp-system-toolsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create the
/etc/pcp/pmlogger/control.d/remotefile with the following content:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Replace 192.168.4.13, 192.168.4.14, 192.168.4.62 and 192.168.4.69 with the client IP addresses.
Enable the
pmcdandpmloggerservices:systemctl enable pmcd pmlogger systemctl restart pmcd pmlogger
# systemctl enable pmcd pmlogger # systemctl restart pmcd pmloggerCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Ensure that you can access the latest archive file from each directory:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The archive files from the
/var/log/pcp/pmlogger/directory can be used for further analysis and graphing.
8.6. Systemd units and pmlogger Copiar enlaceEnlace copiado en el portapapeles!
When you deploy the pmlogger service, either as a single host monitoring itself or a pmlogger farm with a single host collecting metrics from several remote hosts, there are several associated systemd service and timer units that are automatically deployed. These services and timers provide routine checks to ensure that your pmlogger instances are running, restart any missing instances, and perform archive management such as 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.timerunit, which is required by thepmlogger.serviceunit. pmlogger_check-
Performs half-hourly checks that
pmloggerinstances are running. Restarts any missing instances and performs any required compression tasks. Triggered by thepmlogger_check.timerunit, which is required by thepmlogger.serviceunit. pmlogger_farm_check-
Checks the status of all configured
pmloggerinstances. Restarts any missing instances. Migrates all non-primary instances to thepmlogger_farmservice. Triggered by thepmlogger_farm_check.timer, which is required by thepmlogger_farm.serviceunit that is itself required by thepmlogger.serviceunit.
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 via 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, if pmcd on one monitored host is updated during the logging interval, the semantics for some metrics on the host might be updated, thus making the new archives incompatible with the previously recorded archives from that host. For more information see the pmlogrewrite(1) man page.
Managing systemd services triggered by pmlogger
You can create an automated custom archive management system for data collected by your pmlogger instances. This is done using control files. These control files are:
For the primary
pmloggerinstance:-
etc/pcp/pmlogger/control -
/etc/pcp/pmlogger/control.d/local
-
For the remote hosts:
/etc/pcp/pmlogger/control.d/remoteReplace remote with your desired file name.
- NOTE
-
The primary
pmloggerinstance must be running on the same host as thepmcdit connects to. You do not need to have a primary instance and you might not need it in your configuration if one central host is collecting data on severalpmloggerinstances connected topmcdinstances running on remote host
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:
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. There can only be one primary logger across all the files in your configuration and it must be running on the same host as thepmcdit connects to. S?-
Stands for “Socks?” This field indicates if this logger instance needs to use the
SOCKSprotocol to connect topmcdthrough a firewall,y, or not,n. directory- All archives associated with this line are created in this directory.
argsArguments passed to
pmlogger.The default values for the
argsfield 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.serviceruns. The default value of24h10mindicates 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 essentially 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_dailyorpmlogger_check.
8.7. Replaying the PCP log archives with pmrep Copiar enlaceEnlace copiado en el portapapeles!
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.
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
- PCP is installed. For more information, see Installing and enabling PCP.
-
The
pmloggerservice is enabled. For more information, see Enabling the pmlogger service. Install the
pcp-guipackage:dnf install pcp-gui
# dnf install pcp-guiCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Procedure
Display the data on the metric:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The mentioned example displays the data on the
disk.dev.writemetric collected in an archive at a 5 second interval in comma-separated-value format.NoteReplace
20211128in this example with a filename containing thepmloggerarchive you want to display data for.
8.8. Enabling PCP version 3 archives Copiar enlaceEnlace copiado en el portapapeles!
Performance Co-Pilot (PCP) archives store historical values of PCP metrics recorded from a single host and support retrospective performance analysis. PCP archives contain all the important metric data and metadata needed for offline or offsite analysis. These archives can be read by most PCP client tools or dumped raw by the pmdumplog tool.
From PCP 6.0, version 3 archives are supported in addition to version 2 archives. Version 2 archives remain the default and will continue to receive long-term support for backwards compatibility purposes in addition to version 3 archives receiving long-term support from RHEL 9.2 and on.
Using PCP version 3 archives offers the following benefits over version 2:
- Support for instance domain change-deltas
- Y2038-safe timestamps
- Nanosecond-precision timestamps
- Arbitrary timezones support
- 64-bit file offsets used for individual volumes larger than 2GB
Prerequisites
- PCP is installed. For more information, see Installing and enabling PCP.
Procedure
Open the
/etc/pcp.conffile in a text editor of your choice and set the PCP archive version:PCP_ARCHIVE_VERSION=3
PCP_ARCHIVE_VERSION=3Copy to Clipboard Copied! Toggle word wrap Toggle overflow Restart the
pmloggerservice to apply your configuration changes:systemctl restart pmlogger.service
# systemctl restart pmlogger.serviceCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Create a new PCP archive log using your new configuration. For more information, see Logging performance data with pmlogger.
Verification
Verify the version of the archive created with your new configuration:
pmloglabel -l /var/log/pcp/pmlogger/20230208
# pmloglabel -l /var/log/pcp/pmlogger/20230208 Log Label (Log Format Version 3) Performance metrics from host host1 commencing Wed Feb 08 00:11:09.396 2023 ending Thu Feb 07 00:13:54.347 2023Copy to Clipboard Copied! Toggle word wrap Toggle overflow