Load & Memory monitoring using SAR command – Linux

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

sar -q

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.

Examples

>> 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

>> sar -q 1 5

It lists load averages 5 times from when we enter this with an interval of 1 sec.

sar

>> 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

SAR for memory monitoring purpose

sar -r 

Report memory details.

Examples

>> 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

>> 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

>> sar -r -f /var/log/sa/sa23

Fetch data from /var/log/sa/sa23.

sar

That’s it!!

Related posts

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?

Post navigation

Arunlal A

Senior System Developer at Zeta. Linux lover. Traveller. Let's connect! Whether you're a seasoned DevOps pro or just starting your journey, I'm always eager to engage with like-minded individuals. Follow my blog for regular updates, connect on social media, and let's embark on this DevOps adventure together! Happy coding and deploying!

6 thoughts on “Load & Memory monitoring using SAR command – Linux

  1. Hi Arun,
    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.

  2. nice article!
    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;)
    danielwestermann.com/2013/04/11/visualize-your-sar-data-with-ksar/

    Cheers,
    Dmitry Shevkoplyas

Leave a Reply

Your email address will not be published. Required fields are marked *