Install and configure sysstat/sar on Ubuntu/Debian server

Hi,

The sar/sysstat is a very useful and effective tool to monitor your server resource usage, by installing it you will be able to find out the server’s load history, resource usage etc. The steps to install it on a Ubuntu/Debian distro is given below.

Installation of SAR on Ubuntu/Debian

In a debian based server we use the “apt-get” command to install the SAR.

Step 1 : SSH to server as root user.

Step 2 : Run the below command to install the SAR utility.

 apt-get install sysstat 

There is a chance of getting the following error if you are not configured the sysstat properly.

Cannot open /var/log/sysstat/sa02: No such file or directory
Please check if data collecting is enabled in /etc/default/sysstat 

Fix: Open “/etc/default/sysstat” using your favorite file editor and change ENABLED=”false” to ENABLED=”true”
Step 3: One more thing to do, change the collection interval from every 10 minutes to every 2 minutes.

----
vi /etc/cron.d/sysstat
Change
5-55/10 * * * * root command -v debian-sa1 > /dev/null && debian-sa1 1 1
To
*/2 * * * * root command -v debian-sa1 > /dev/null && debian-sa1 1 1
----

Step 4: Restart the service.

service sysstat restart
Or
/etc/init.d/sysstat restart 

Thank you!!!