Load & Memory monitoring using SAR

Is there any way to get my server’s load and memory usage history from commandline?

Yes, it’s possible by using the commandline 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. 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 

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

Examples

>> sar -q  

It simply list current day’s load averages starting from 12:00:00, with 10 minute interval.

sar

>> sar -q 1 5

It list 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.

sar

SAR for memory monitoring purpose

sar -r 

Report memory details.

Examples

>> sar -r 

It simply list current day’s memory usage averages starting from 12:00:00, with 10 minute interval.

sar

>> sar -r 1 5

It list memory usage averages 5 times from when we enter this with an interval of 1 sec.

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?

Arunlal Ashok

Linux Server Administrator. I’m managing Linux servers since 2012. I started this blog to share and discuss my ideas.

Any questions? Write to arun (@) crybit.com

You may also like...

5 Responses

  1. Zeinab says:

    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. Rajesh Jayaraman says:

    How can I take one week server load using sar commond

  3. Dmitry Shevkoplyas says:

    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 *