How To Install SAR on Ubuntu 24.04 LTS
In this tutorial, we will show you how to install SAR on Ubuntu 24.04 LTS. System performance monitoring is crucial for maintaining the health and efficiency of your Linux servers. SAR (System Activity Reporter) is a powerful tool that allows you to collect, report, and analyze system performance data, including CPU usage, memory utilization, disk I/O, and network statistics.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo
‘ to the commands to get root privileges. I will show you the step-by-step installation of the SAR (System Activity Reporter) on Ubuntu 24.04 (Noble Numbat). You can follow the same instructions for Ubuntu 22.04 and any other Debian-based distribution like Linux Mint, Elementary OS, Pop!_OS, and more as well.
Prerequisites
- A server running one of the following operating systems: Ubuntu and any other Debian-based distribution like Linux Mint.
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- SSH access to the server (or just open Terminal if you’re on a desktop).
- An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies.
- An Ubuntu 24.04 system with root access or a user with sudo privileges.
Install SAR on Ubuntu 24.04 LTS Noble Numbat
Step 1. Updating the Package Repository.
To ensure a smooth installation process, it’s essential to update your system packages to their latest versions. Open a terminal and run the following command:
sudo apt update
This will fetch the latest package information and upgrade any outdated packages to their newest versions.
Step 2. Installing SAR (System Activity Reporter) on Ubuntu 24.04.
SAR is part of the sysstat package, which contains various system performance monitoring tools. To install SAR, execute the following command:
sudo apt install sysstat
After installation, you need to enable and start the sysstat service to begin collecting system performance data. Run the following commands:
sudo systemctl enable sysstat sudo systemctl start sysstat
To verify that the service is running correctly, use the command:
sudo systemctl status sysstat
If the service is active and running, you should see output similar to:
● sysstat.service - Resets System Activity Logs Loaded: loaded (/lib/systemd/system/sysstat.service; enabled; vendor preset: enabled) Active: active (exited) since Mon 2024-06-24 07:30:01 UTC; 5min ago Main PID: 12345 (code=exited, status=0/SUCCESS) Tasks: 0 (limit: 9443) Memory: 0B CPU: 0 CGroup: /system.slice/sysstat.service
Step 4. Configure Sysstat.
By default, SAR is not enabled after installation. To enable it, open the /etc/default/sysstat
file using your preferred text editor:
sudo nano /etc/default/sysstat
Locate the line that says ENABLED="false"
and change it to ENABLED="true"
. Save the file and exit the editor.
Next, restart the sysstat service to apply the changes:
sudo systemctl restart sysstat
SAR collects data every 10 minutes by default. You can verify this by checking the /etc/cron.d/sysstat
file.
Step 5. Using SAR Commands.
Now that SAR is installed and configured, let’s explore some basic and advanced commands to monitor your system’s performance.
- Basic SAR Commands
To view CPU usage, use the following command:
sar -u 1 3
To monitor memory usage, including used memory, free memory, cache, and buffers, run:
sar -r 1 3
To view disk I/O statistics, use the command:
sar -d 1 3
To monitor network usage, including network speed, IPV4, TCPV4, ICMPV4 traffic, and errors, run:
sar -n DEV 1 3 | egrep -v lo
- Scheduling SAR Reports
You can schedule SAR reports using cron jobs. To edit the crontab file, use the command:
sudo nano /etc/cron.d/sysstat
Modify the file to schedule reports at your desired intervals. For example, to generate a report every 30 minutes, add the following line:
*/30 * * * * root /usr/lib/sysstat/sadc -S DISK 1 1 -S XALL 60 6 /var/log/sysstat/sa`date +\%d`
Save the file and exit the editor.
Congratulations! You have successfully installed SAR. Thanks for using this tutorial for installing SAR (System Activity Reporter) on the Ubuntu 24.04 LTS system. For additional help or useful information, we recommend you check the Sysstat website.