Chapter 22. Monitoring performance by using the metrics RHEL System Role
As a system administrator, you can use the metrics RHEL System Role with any Ansible Automation Platform control node to monitor the performance of a system.
22.1. Introduction to the metrics System Role Copy linkLink copied to clipboard!
RHEL System Roles is a collection of Ansible roles and modules that provide a consistent configuration interface to remotely manage multiple RHEL systems. The metrics System Role configures performance analysis services for the local system and, optionally, includes a list of remote systems to be monitored by the local system. The metrics System Role enables you to use pcp to monitor your systems performance without having to configure pcp separately, as the set-up and deployment of pcp is handled by the playbook.
| Role variable | Description | Example usage |
|---|---|---|
| metrics_monitored_hosts |
List of remote hosts to be analyzed by the target host. These hosts will have metrics recorded on the target host, so ensure enough disk space exists below |
|
| metrics_retention_days | Configures the number of days for performance data retention before deletion. |
|
| metrics_graph_service |
A boolean flag that enables the host to be set up with services for performance data visualization via |
|
| metrics_query_service |
A boolean flag that enables the host to be set up with time series query services for querying recorded |
|
| metrics_provider |
Specifies which metrics collector to use to provide metrics. Currently, |
|
| metrics_manage_firewall |
Uses the |
|
| metrics_manage_selinux |
Uses the |
|
For details about the parameters used in metrics_connections and additional information about the metrics System Role, see the /usr/share/ansible/roles/rhel-system-roles.metrics/README.md file.
22.2. Using the metrics System Role to monitor your local system with visualization Copy linkLink copied to clipboard!
This procedure describes how to use the metrics RHEL System Role to monitor your local system while simultaneously provisioning data visualization via Grafana.
Prerequisites
- The Ansible Core package is installed on the control machine.
-
You have the
rhel-system-rolespackage installed on the machine you want to monitor.
Procedure
Configure
localhostin the/etc/ansible/hostsAnsible inventory by adding the following content to the inventory:localhost ansible_connection=local
localhost ansible_connection=localCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create an Ansible playbook with the following content:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Run the Ansible playbook:
ansible-playbook name_of_your_playbook.yml
# ansible-playbook name_of_your_playbook.ymlCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteSince the
metrics_graph_serviceboolean is set to value="yes",Grafanais automatically installed and provisioned withpcpadded as a data source. Since metrics_manage_firewall and metrics_manage_selinux are both set to true, the metrics role will use the firewall and selinux system roles to manage the ports used by the metrics role.-
To view visualization of the metrics being collected on your machine, access the
grafanaweb interface as described in Accessing the Grafana web UI.
22.3. Using the metrics System Role to setup a fleet of individual systems to monitor themselves Copy linkLink copied to clipboard!
This procedure describes how to use the metrics System Role to set up a fleet of machines to monitor themselves.
Prerequisites
- The Ansible Core package is installed on the control machine.
-
You have the
rhel-system-rolespackage installed on the machine you want to use to run the playbook. - You have the SSH connection established.
Procedure
Add the name or IP of the machines you want to monitor via the playbook to the
/etc/ansible/hostsAnsible inventory file under an identifying group name enclosed in brackets:[remotes] webserver.example.com database.example.com
[remotes] webserver.example.com database.example.comCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create an Ansible playbook with the following content:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteSince
metrics_manage_firewallandmetrics_manage_selinuxare both set to true, the metrics role will use thefirewallandselinuxroles to manage the ports used by themetricsrole.Run the Ansible playbook:
ansible-playbook name_of_your_playbook.yml -k
# ansible-playbook name_of_your_playbook.yml -kCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Where the -k prompt for password to connect to remote system.
22.4. Using the metrics System Role to monitor a fleet of machines centrally via your local machine Copy linkLink copied to clipboard!
This procedure describes how to use the metrics System Role to set up your local machine to centrally monitor a fleet of machines while also provisioning visualization of the data via grafana and querying of the data via redis.
Prerequisites
- The Ansible Core package is installed on the control machine.
-
You have the
rhel-system-rolespackage installed on the machine you want to use to run the playbook.
Procedure
Create an Ansible playbook with the following content:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Run the Ansible playbook:
ansible-playbook name_of_your_playbook.yml
# ansible-playbook name_of_your_playbook.ymlCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteSince the
metrics_graph_serviceandmetrics_query_servicebooleans are set to value="yes",grafanais automatically installed and provisioned withpcpadded as a data source with thepcpdata recording indexed intoredis, allowing thepcpquerying language to be used for complex querying of the data. Sincemetrics_manage_firewallandmetrics_manage_selinuxare both set to true, themetricsrole will use thefirewallandselinuxroles to manage the ports used by themetricsrole.-
To view graphical representation of the metrics being collected centrally by your machine and to query the data, access the
grafanaweb interface as described in Accessing the Grafana web UI.
22.5. Setting up authentication while monitoring a system using the metrics System Role Copy linkLink copied to clipboard!
PCP supports the scram-sha-256 authentication mechanism through the Simple Authentication Security Layer (SASL) framework. The metrics RHEL System Role automates the steps to setup authentication using the scram-sha-256 authentication mechanism. This procedure describes how to setup authentication using the metrics RHEL System Role.
Prerequisites
- The Ansible Core package is installed on the control machine.
-
You have the
rhel-system-rolespackage installed on the machine you want to use to run the playbook.
Procedure
Include the following variables in the Ansible playbook you want to setup authentication for:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteSince
metrics_manage_firewallandmetrics_manage_selinuxare both set to true, themetricsrole will use thefirewallandselinuxroles to manage the ports used by themetricsrole.Run the Ansible playbook:
ansible-playbook name_of_your_playbook.yml
# ansible-playbook name_of_your_playbook.ymlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification steps
Verify the
saslconfiguration:pminfo -f -h "pcp://ip_adress?username=your_username" disk.dev.read
# pminfo -f -h "pcp://ip_adress?username=your_username" disk.dev.read Password: disk.dev.read inst [0 or "sda"] value 19540Copy to Clipboard Copied! Toggle word wrap Toggle overflow ip_adress should be replaced by the IP address of the host.
22.6. Using the metrics System Role to configure and enable metrics collection for SQL Server Copy linkLink copied to clipboard!
This procedure describes how to use the metrics RHEL System Role to automate the configuration and enabling of metrics collection for Microsoft SQL Server via pcp on your local system.
Prerequisites
- The Ansible Core package is installed on the control machine.
-
You have the
rhel-system-rolespackage installed on the machine you want to monitor. - You have installed Microsoft SQL Server for Red Hat Enterprise Linux and established a 'trusted' connection to an SQL server. See Install SQL Server and create a database on Red Hat.
- You have installed the Microsoft ODBC driver for SQL Server for Red Hat Enterprise Linux. See Red Hat Enterprise Server and Oracle Linux.
Procedure
Configure
localhostin the/etc/ansible/hostsAnsible inventory by adding the following content to the inventory:localhost ansible_connection=local
localhost ansible_connection=localCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create an Ansible playbook that contains the following content:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteSince
metrics_manage_firewallandmetrics_manage_selinuxare both set to true, themetricsrole will use thefirewallandselinuxroles to manage the ports used by themetricsrole.Run the Ansible playbook:
ansible-playbook name_of_your_playbook.yml
# ansible-playbook name_of_your_playbook.ymlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification steps
Use the
pcpcommand to verify that SQL Server PMDA agent (mssql) is loaded and running:Copy to Clipboard Copied! Toggle word wrap Toggle overflow