Using a systemd timer to collect supplemental system utilization statistics in RHEL High Availability or Resilient Storage Clusters

Solution Verified - Updated

Environment

  • Red Hat Enterprise Linux (all versions) with the Pacemaker High Availability Add-on

Issue

  • To troubleshoot a cluster issue, Red Hat support has suggested using the ha-resourcemon.sh script but crontab is not available in my environment.

Resolution

On RHEL7, RHEL8 and RHEL9, a systemd timer can be used instead of crontab to periodically run a task.

Using the Collecting supplemental system utilization statistics for fence events or performance problems in RHEL High Availability or Resilient Storage clusters as a guide :

  1. Create a new file named /etc/systemd/system/ha-resourcemon.service :

    [Unit]
    Description=Execute ha-resourcemon.sh script
    
    [Service]
    ExecStart=/bin/bash /path/to/ha-resourcemon.sh 20 179 /<logdata> 2
    

    Note: Please adjust /path/to/ and <logdata> according to where you've put the ha-resourcemon.sh script and where you want to store the data. Please refer to the main Collecting supplemental system utilization statistics for fence events or performance problems in RHEL High Availability or Resilient Storage clusters article for further reference.

  2. Create a new file named /etc/systemd/system/ha-resourcemon.timer :

    [Unit]
    Description=Run ha-resourcemon.service every top of the hour 
    
    [Timer]
    OnCalendar=*-*-* *:00:00
    
    [Install]
    WantedBy=multi-user.target
    
  3. Enable the timer

    $ systemctl daemon-reload
    $ systemctl enable ha-resourcemon.timer
    
  4. The service should start up at the top of the next hour. As configured, the script should run for 179 20 second increments, or 59 minutes and 40 seconds.

  5. The ha-resourcemon.service can be monitored using the journalctl command:

    $ journalctl  -u ha-resourcemon.service  |grep -v 'Cannot get stats strings information'
    Aug 08 17:00:10 node1  systemd[1]: Started haresourcemon.service - Execute ha-resourcemon script.
    Aug 08 17:59:52 node1 systemd[1]: haresourcemon.service: Deactivated successfully.
    Aug 08 17:59:52 node1 systemd[1]: haresourcemon.service: Consumed 17.314s CPU time.
    Aug 08 18:00:39 node1 systemd[1]: Started haresourcemon.service - Execute ha-resourcemon script.
    Aug 08 19:00:22 node1 systemd[1]: haresourcemon.service: Deactivated successfully.
    Aug 08 19:00:22 node1 systemd[1]: haresourcemon.service: Consumed 17.360s CPU time.
    Aug 08 19:00:22 node1 systemd[1]: Started haresourcemon.service - Execute ha-resourcemon script.
    Aug 08 20:00:05 node1 systemd[1]: haresourcemon.service: Deactivated successfully.
    Aug 08 20:00:05 node1 systemd[1]: haresourcemon.service: Consumed 17.327s CPU time.
    

Root Cause

  • Red Hat support has asked us to collect supplemental system utilization statistics to troubleshoot but crontab is not available.
SBR
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.