How to change the collection interval of the SAR data in RHEL8 and newer?
Environment
- Red Hat Enterprise Linux 10
- Red Hat Enterprise Linux 9
- Red Hat Enterprise Linux 8
- Systemd Timers
- Sysstat
Issue
SARcomes with 10 mins data collection interval by default. How to change it to an interval to one minute or less?
Resolution
Important: The following procedures apply only for RHEL8 and newer releases that use Systemd Timers. For RHEL7 and older, please refer the solution How to change the collection interval of SAR data less than 1 minute in RHEL7 and older?
-
Run the following commands to edit the
sysstat-collect.timer:# export SYSTEMD_EDITOR=/usr/bin/vi # systemctl edit sysstat-collect.timer -
To se the collect interval a value above 1 minute add the following entries:
[Unit] Description=Run system activity accounting tool every 1 minute [Timer] OnCalendar= OnCalendar=*:00/1 -
To se the collect interval a value under one 1 minute add the following entries:
[Unit] Description=Run system activity accounting tool every 30 seconds [Timer] OnCalendar= OnCalendar=*-*-* *:*:00,30Note: The blank
OnCalendar=directive is there to remove the original setting. -
After changing the timer unit, run
systemctl daemon-reloadso the changes can make effect:# systemctl daemon-reload
Diagnostic Steps
-
Run a
systemctl cat sysstat-collect.timeron the unit file it outputs the entire unit file including the override:# systemctl cat sysstat-collect.timer # /usr/lib/systemd/system/sysstat-collect.timer # /usr/lib/systemd/system/sysstat-collect.timer # (C) 2014 Tomasz Torcz <tomek@pipebreaker.pl> # # sysstat-11.7.3 systemd unit file: # Activates activity collector every 10 minutes [Unit] Description=Run system activity accounting tool every 10 minutes [Timer] OnCalendar=*:00/10 [Install] WantedBy=sysstat.service # /etc/systemd/system/sysstat-collect.timer.d/override.conf <-- shows our override file with our changes listed after it [Unit] Description=Run system activity accounting tool every 1 minute [Timer] OnCalendar= OnCalendar=*:00/1 -
Run a
systemctl daemon-reloadto have systemd re-read it's unit file configurations. -
Doing a
systemctl status sysstat-collect.timerof the unit file we see the timer is showing as a drop-in:# systemctl status sysstat-collect.timer ● sysstat-collect.timer - Run system activity accounting tool every 1 minute Loaded: loaded (/usr/lib/systemd/system/sysstat-collect.timer; disabled; vendor preset: disabled) Drop-In: /etc/systemd/system/sysstat-collect.timer.d <-- drop-in directory └─override.conf <-- our actual override file Active: inactive (dead) Trigger: n/a -
We can then start the timer (or restart the timer if it's already been started):
# systemctl start sysstat-collect.timer Created symlink /etc/systemd/system/sysstat.service.wants/sysstat-collect.timer → /usr/lib/systemd/system/sysstat-collect.timer. # systemctl start sysstat-collect.timer # systemctl status sysstat-collect.timer ● sysstat-collect.timer - Run system activity accounting tool every 1 minute Loaded: loaded (/usr/lib/systemd/system/sysstat-collect.timer; enabled; vendor preset: disabled) Drop-In: /etc/systemd/system/sysstat-collect.timer.d └─override.conf Active: active (waiting) since Thu 2020-05-28 09:53:15 EDT; 1s ago <-- In the active(waiting) state as it's started, waiting to run on the time. Trigger: Thu 2020-05-28 09:54:00 EDT; 42s left <-- shows the amount of time left before it runs again May 28 09:53:15 dhcp-1-181-242.sd.lab.cee.rdu2.redhat.com systemd[1]: Started Run system activity accounting tool every 1 minute.
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.