Monitoring servers are very important for every server administrator. There are a lot of command line tools are available to monitor server resource usages. The Sar or Sysstat is one of the great command-line tool to monitor the server resource usage. This will track a record of resource usages in server. This can be used for your system resource usage analysis in case of any outage occurs. A great tool for postmortem purpose. In this article we’re discussing the steps to install this utility on Debian based system. The installation process is very simple and can be done using the default package manager.
We can simply find out the resource usages history by using the command “sar” with its switches like ‘q’, ‘r’ etc..
>> Load & Memory monitoring using SAR <<
A lot of switches are available with “sar” command to check different things. Here, CryBit explains the basic installation steps of sar on Debian servers.
Installation of SAR on Ubuntu/Debian
We can simply install and configure the SAR on Linux servers. In debian based server we can use the command “apt-get” to install the SAR utility.
Step I : SSH to the server as root user.
Step II : Execute the below command to install the SAR utility.
# apt-get install sysstat
That’s it! You may get the below pasted 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
Solution
Open “/etc/default/sysstat” using your favorite file editor and change ENABLED=”false” to ENABLED=”true”
vi /etc/default/sysstat
----
# Should sadc collect system activity informations? Valid values
# are "true" and "false". Please do not put other values, they
# will be overwritten by debconf!
ENABLED="true"
----
Step III : 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 IV : Restart the service.
service sysstat restart
Or
/etc/init.d/sysstat restart
That’s it! Install SAR and relax 🙂
Related Links:
1, Load & Memory monitoring using SAR
2, Load monitoring in Linux servers
How to send this SAR report to automatically on my email id ?
You may have to create/define a cronjob for this.
I did this on Amazon EC2 Ubuntu virtual machine. It worked perfectly. I didn’t need to restart sysstat service.
Hi
I am using CentOS Linux release 7 and i am not finding /etc/default/sysstat file for enabling data collection.
Please help me where exaclty i have to enable as ENABLED=”true”?
thanks
Awesome post!!! Extremely helpful!!! Thank you so much!!!
Thanks for the kind words of appreciation, Cris!!
Thanks
You’re most welcome, Ahmed!
very nice post and explanation.
screenshots are a great helper.
You are most welcome, João!
You may want to mention the “No such file or directory” failure can occur if you run the “sar” command (i.e. test it by running sar once).
Cheers!
Cool!, just what i needed 🙂
You are most welcome, Talo!!
Thanks for your explanation! Very useful!
You are most welcome!!
sometimes u have to say thanks……
Hi Akhilendra,
You are most welcome!
Thank you. I forgot to change enable=”true”.
Thanks!
You’re most welcome, Stefano!
Why? Why is this set to “false” on ubuntu?
Just to message to thank you 🙂
Most welcome, Jo!
Thank you!
Most welcome!!
I did the recommendations however I am still unable to run the command sar. I get a prompt cannot open /var/log/sysstat.sa23: No such file or directory.
Please check if data collecting is enabled.
Hope for suggestion on how to resolve this.
Thanks!
Hey Lawrence,
Did you restart the sysstat daemon after the change in configuration file?
On systemd systems you need to enable following services:
– sysstat-collect.timer
– sysstat-summary.timer
so it means that following commands:
systemctl start sysstat-collect.timer
systemctl start sysstat-summary.timer
and also enable with both services.