Deploy sysstat
to collect system performance data every 60 seconds, enabling real-time visibility and historical analysis.
Install the sysstat
package (includes sar
, sadc
, etc.):
sudo dnf install -y sysstat
Modify cron to collect every minute instead of 10:
sudo sed -i 's|^\*/10 \* \* \* \* root /usr/lib64/sa/sa1 1 1|* * * * * root /usr/lib64/sa/sa1 1 1|' /etc/cron.d/sysstat
This ensures per-minute data capture.
Enable and start the sysstat service:
sudo systemctl enable --now sysstat
Edit /etc/sysconfig/sysstat
for retention and metric control:
sudo vi /etc/sysconfig/sysstat
Suggested changes:
HISTORY=90 # Retain 90 days of logs
COMPRESSAFTER=31 # Compress old logs after 31 days
SADC_OPTIONS=" -S ALL" # Collect all system stats (CPU, disk, memory, etc.)
Check log presence in /var/log/sa/
:
ls -lh /var/log/sa/
Use sar
to review collected data:
sar -u # CPU
sar -r # Memory
sar -b # Disk I/O
sar -n DEV # Network
View specific day's data:
sar -u -f /var/log/sa/sa24
---
- name: Configure sysstat for 1-minute monitoring on AlmaLinux 9
hosts: almalinux_nodes
become: true
tasks:
- name: Ensure sysstat package is installed
ansible.builtin.package:
name: sysstat
state: present
- name: Set sysstat data collection interval to 60 seconds
ansible.builtin.lineinfile:
path: /etc/cron.d/sysstat
regexp: '^\*/10 \* \* \* \* root /usr/lib64/sa/sa1 1 1'
line: '* * * * * root /usr/lib64/sa/sa1 1 1'
backup: yes
- name: Ensure sysstat service is enabled and started
ansible.builtin.service:
name: sysstat
state: started
enabled: true
- name: Set comprehensive data collection
ansible.builtin.lineinfile:
path: /etc/sysconfig/sysstat
regexp: '^SADC_OPTIONS='
line: 'SADC_OPTIONS=" -S ALL"'
backup: yes
- name: Set data retention to 90 days
ansible.builtin.lineinfile:
path: /etc/sysconfig/sysstat
regexp: '^HISTORY='
line: 'HISTORY=90'
backup: yes
ansible-playbook deploy_sysstat.yml -l <your_host_or_group>
sar -u # Daily summary
sar -u 1 5 # Real-time stats (5 samples every 1s)
%user
: App usage%iowait
: Disk bottlenecks%steal
: VM CPU contention
sar -r
kbavail
,%memused
,%swpused
indicate memory pressure
sar -b # Global I/O stats
sar -d # Per-device I/O
- Look at
tps
,await
,%util
for bottlenecks
sar -n DEV # Network traffic
sar -n EDEV # Network errors
- High
rxerr/s
,txerr/s
,coll/s
β NIC or network problem
- Use
-S DISK
,-S XALL
, or-S ALL
depending on server role - Integrate with Grafana or SIEM for full-stack visibility
Prepared by: Harisfazillah Jamel
ποΈ 24 July 2025