we’re going to take a look at the System Activity Reporter, the sar command, which will help us get a historical view of our server’s performance. A set of statistical information, such as CPU load, memory paging, memory utilization, swap usage, network I/O, and much more, is captured. I’ll show you how to install it, determine when it runs, and run it manually as well. If your server is a production server, I hope you’ve already installed all available updates; that’s very important. The first thing we’re going to do is install the sar command.
Table of Contents
Updating Package Sources:
sudo apt update
- we’ll install the package that includes the sar command, sysstat, by running:
Installing sysstat:
sudo apt install sysstat
- it was already installed. It may or may not be installed on your end, but in my case, I didn’t have to install this package because it was already present.
However, just having the sysstat package installed isn’t enough by itself. We’re going to customize some defaults. Specifically, we’ll run:
Configuring sysstat:
sudo nano /etc/default/sysstat

ENABLED="true"
root@ip-172-31-22-37:~# systemctl restart sysstat
- As you can see, collecting status is currently disabled by default. We’ll change this to true, save the file by pressing Ctrl+O and Enter, and then Ctrl+X to exit and restart the sysstat services.
Why Enable Sysstat?
By default, sysstat might be installed but not active. This means it won’t collect and store any performance data unless explicitly enabled. Changing the ENABLED parameter to true ensures that the sysstat services start collecting data at regular intervals. This data can be crucial for:
- Performance Monitoring: Regularly collected data helps monitor system performance and identify trends over time.
- Troubleshooting: Historical performance data can be invaluable when diagnosing and resolving issues.Capacity Planning: Helps in understanding the resource utilization trends and planning for future needs.
- Capacity Planning: Helps in understanding the resource utilization trends and planning for future needs.
Additional Configuration Files:
cat /etc/cron.d/sysstat
The defaults would be fine, but this file gives us an activity report every 10 minutes and rotates the statistics file at the end of the day. You can customize this if needed, but again, the defaults would be fine. Now that we have the sar command installed and the defaults set up to run every 10 minutes, we could have a data file on our file system. For example, you can run:
ls /var/log/sysstat
You might see a data file in this directory. If you don’t, wait a few minutes because sysstat runs every 10 minutes by default. In my case, I customized mine to run every two minutes for this recording, so I have a data file.
To run the sar command, we’ll need root privileges. We can run:
sudo sar -u -f /var/log/sysstat/sa22
- Here, sa22 corresponds to the 22nd of the month. Press Enter, and we see useful information about the CPU, including the date and load average.
using sar -u:
- Reports CPU utilization (user, system, idle time).
root@ip-172-31-22-37:~# sar -u

using sar -r:
- Reports memory usage statistics (free memory, used memory).
root@ip-172-31-22-37:~# sar -r

using sar -S:
- Reports swap statistics (swap in/out rates).
root@ip-172-31-22-37:~# sar -s

using sar -b:
- Reports paging statistics, including page faults and page swaps.
root@ip-172-31-22-37:~# sar -b

If your server is running slowly and you’re unsure why, checking the I/O information can help identify the bottleneck.The man pages for the sar command. The sar command runs in the background by default and collects information over time, helping you understand your server’s performance historically.