sar: "Please check if data collecting is enabled" fix (Ubuntu, Debian, RHEL)
sar says "Cannot open /var/log/sysstat/saDD" because sysstat collection is off. On Ubuntu and Debian, editing ENABLED="true" is not enough anymore: the systemd timers have to be on. Here's the fix for Ubuntu 24.04, Debian 12/13 and RHEL.
Cannot open /var/log/sysstat/sa15: No such file or directory
Please check if data collecting is enabled
sar prints this when there's no data file for today. The tool works. Nothing has been collecting statistics, because sysstat ships with collection turned off on Ubuntu and Debian, and the service isn't enabled by default on RHEL.
The fix on Ubuntu and Debian:
sudo dpkg-reconfigure sysstat # answer "Yes"
The fix on RHEL, Rocky, AlmaLinux and Fedora:
sudo systemctl enable --now sysstat
Then wait up to 10 minutes and run sar again. If you need numbers right now, skip to Get stats without waiting.
Below is why the old advice (set ENABLED="true" and restart) only half works on current Ubuntu, and how to check that collection is really running.
Why the file is missing
sar without arguments reads today's binary file: /var/log/sysstat/saDD on Debian and Ubuntu, /var/log/sa/saDD on RHEL, where DD is the day of the month. Those files are written by sa1, which a timer runs every 10 minutes. No timer, no file, and you get the error.
On a fresh Ubuntu 24.04 install (sysstat 12.6.1), apt install sysstat leaves /etc/default/sysstat at:
ENABLED="false"
The package installs three systemd units, sysstat.service, sysstat-collect.timer and sysstat-summary.timer. Because of that false, the install script then turns them off.
Why ENABLED="true" plus a restart isn't enough anymore
For years the standard fix was to edit /etc/default/sysstat, set ENABLED="true" and restart the service. That came from the cron era. On a systemd machine it fails in a sneaky way.
- The cron job in
/etc/cron.d/sysstatcallsdebian-sa1, and that script exits right away when systemd is running. So theENABLEDline in the file isn't what controls collection anymore. The systemd timers are. systemctl restart sysstatrunssa1 --bootonce. That creates today's file with a "LINUX RESTART" line, so the error goes away and it looks fixed.- The
sysstat-collect.timeris still disabled, though. No new samples get written, and the next day the error is back.
That's why the right tool on Debian and Ubuntu is dpkg-reconfigure. It writes ENABLED="true" and enables and starts the timers in one go. It also keeps the package's own setting in sync, so a later apt upgrade won't switch collection back off.
Fix on Ubuntu and Debian
Interactive:
sudo dpkg-reconfigure sysstat
Answer Yes to "Activate sysstat's cron job?". The wording still says cron, but on systemd it switches the timers.
Non-interactive, for scripts or Ansible:
sudo sed -i 's/^ENABLED=.*/ENABLED="true"/' /etc/default/sysstat
sudo dpkg-reconfigure -f noninteractive sysstat
The config script reads ENABLED from the file, so the second command applies it.
If you'd rather do it by hand with systemctl, enable all three units:
sudo systemctl enable --now sysstat sysstat-collect.timer sysstat-summary.timer
That works right away. Still set ENABLED="true" in /etc/default/sysstat as well, so the package settings match what's running.
Fix on RHEL, Rocky, AlmaLinux and Fedora
Red Hat doesn't use /etc/default/sysstat. Red Hat's own SAR article notes that RHEL 8 and 9 use systemd timers instead of cron, so you just enable the service:
sudo dnf install -y sysstat
sudo systemctl enable --now sysstat
sysstat.service pulls in the collect and summary timers. To be explicit, the Oracle Linux 8 docs enable all three units at once, the same as the manual Debian command above. Data goes to /var/log/sa/saDD.
On old CentOS 6 the equivalent was chkconfig sysstat on and service sysstat start.
Check that collection actually works
Look at the timers:
systemctl list-timers 'sysstat*'
You should see sysstat-collect.timer with a next run within 10 minutes and sysstat-summary.timer at 00:07. If the list is empty, the timers are still disabled.
Then check the data directory:
ls -l /var/log/sysstat/ # Debian/Ubuntu
ls -l /var/log/sa/ # RHEL family
A file named after today's day of the month (sa15 on the 15th) should be there and growing. Once the first sample is in, sar shows something like:
22:25:38 LINUX RESTART (2 CPU)
22:25:38 CPU %user %nice %system %iowait %steal %idle
22:25:40 all 0.25 0.00 0.00 0.00 0.00 99.75
Get stats without waiting
Collection only gives you history from the moment you enabled it. sar can't show yesterday if nothing was recording yesterday. For what's happening right now you don't need the data files at all. Give sar an interval and a count:
sar -u 2 5 # CPU, 5 samples 2 seconds apart
sar -r 2 5 # memory
sar -d 2 5 # disks
To read a specific day later, point sar at the file:
sar -u -f /var/log/sysstat/sa14
For disk and network specifically, I have separate rundowns of Linux disk I/O monitoring tools and commands to monitor network bandwidth.
Change the interval or how long data is kept
The default is a sample every 10 minutes. On a server you're troubleshooting, 1 or 2 minutes is more useful. Override the timer instead of editing the packaged file:
sudo systemctl edit sysstat-collect.timer
[Timer]
OnCalendar=
OnCalendar=*:00/2
The empty OnCalendar= line clears the default before setting the new one. Then:
sudo systemctl daemon-reload
sudo systemctl restart sysstat-collect.timer
Retention is the HISTORY value in /etc/sysstat/sysstat, in days. Keep in mind that more samples and more days mean more disk space.
FAQ
Is this error dangerous?
No. It only means there's no history to show yet, which says nothing about the health of the box: sysstat is installed fine, it just hasn't been told to record anything.
I set ENABLED="true" and the error went away, but sar shows almost nothing. Why?
The restart created today's file with a single "LINUX RESTART" line, but the collect timer is still off. Run sudo dpkg-reconfigure sysstat and answer Yes, or enable sysstat-collect.timer directly.
Does this work in a Docker container?
Containers usually don't run systemd, so the timers never fire. There, sysstat falls back to the cron job, which needs ENABLED="true" and a running cron daemon. For containers, a proper monitoring agent is usually the better tool. If you already run Zabbix, see how to install the Zabbix agent on Linux.
The error mentions yesterday's file, not today's
You ran something like sar -f /var/log/sysstat/sa14 or sar -1, and collection wasn't on that day. That data is gone. Enable collection now, and from tomorrow on you'll have a full day to look back at whenever something spikes overnight.