Is there any way to get my server’s load and memory usage history from commandline?
Yes, it’s possible by using the command-line utility SAR. System Activity Reporter is abbreviated as SAR.
It is an important tool to monitor server’s different important metrics at different points of time. Using SAR it will be possible to monitor the performance of various Linux subsystems (CPU, Memory, I/O..) in real time.
If you had a problem with your server performance, you can check the resource usage history by using SAR utility, so you will get clear idea about resources usage history.
There are a lot of options are available with SAR. Here I’m explaining the usage of load average and memory usage analysing steps.
sysstat - daemon
Top command usages and examples in Unix/Linux
Top command has an important role in Unix/Linux system/server administration side. The command “top” displays a dynamic view of process that are currently running under the system. Read more..
SAR for load monitoring purpose
The above command will report load averages at different times. (It fetch data from /var/log/sa(sysstat)/sa*, where sa* represent the date like sa10,sa11,sa12etc). If you want to fetch details of previous dates, you need to use the switch -f along with -q, and that details are added in the last section of this article.
>> sar -q
It simply lists current day’s load averages starting from 12:00:00, with 10 minute interval and this is the commonly using switch because we mostly check Load history.
>> sar -q 1 5
It lists load averages 5 times from when we enter this with an interval of 1 sec.
>> sar -q -f /var/log/sa/sa23
Previous dates details are stored in the directory “/var/log/sa/”. The switch “f” along with the command SAR can fetch previous days details, so you can check previous dates details from this saved file.
SAR for memory monitoring purpose
Report memory details.
>> sar -r
It simply lists current day’s memory usage averages starting from 12:00:00, with 10 minute interval and it lists all about systems memory usages.
>> sar -r 1 5
It lists memory usage averages 5 times from when we enter this with an interval of 1 sec, and it’s useful for realtime tracking.
>> sar -r -f /var/log/sa/sa23
Fetch data from /var/log/sa/sa23.
1, Server load monitoring commands
2, Online websites monitoring tools to check uptime/downtime
3, What is Rsync over SSH? Command for Rsync over SSH?
6 thoughts on “Load & Memory monitoring using SAR command – Linux”
Your site is absolutely wonderful. Many thanks for putting all these useful tricks of the trade in one place.
I have enabled sar as you have described in your other post and it works. What do I need to do to log all the performance parameter outputs daily to a file, such as to /var/log/sa/sa23, for instance? I have only changed the /etc/cron.d/sysstat entry as you suggested in your tutorial http://crybit.com/sysstat-sar-on-ubuntu-debian/.
Thanks in advance.
How can I take one week server load using sar commond
Please check the “/var/log/sa/” directory for history details.
Let me know if you’ve any questions.
I guess it would be good to mention here ‘kSar’ tool to visualize the collected stats by sar.
Here’s a nice post on how to use it (installation boils down to unzipping the only jar file;)
Really nice. I will check this and will create a blog post.
Thanks for sharing this info.