Generate CPU, Memory and I/O report using SAR command

SAR stands for System Activity Report, as its name suggest sar command is used to collect,report & save CPU, Memory, I/O usage in Unix like operating system. SAR command produce the reports on the fly and can also save the reports in the log files as well.

In this article we will discuss different examples of SAR Command in CentOS  7 & RHEL 7, in case sar is not installed on your system then use the below command to install it.

[[email protected] ~]# yum install sysstat

Start the sadc (system activity data collector) service(sysstat) so that it saves the reports in log file “/var/log/sa/saDD”  where DD represents Current day and already existing files will be archived.

[[email protected] ~]# systemctl start sysstat
[[email protected] ~]# systemctl enable sysstat

It collects the data every 10 minutes and generate its report daily. Below crontab file is responsible for collecting and generating reports.


Below is the Config File of SysStat ( sar command ).


Example:1 Generating CPU Report on the Fly 5 times every 2 seconds.

[[email protected] ~]# sar 2 5
Linux 3.10.0-123.el7.x86_64 (localhost.localdomain)     Monday 26 October 2015     _x86_64_    (2 CPU)

01:43:55  EDT     CPU     %user     %nice   %system   %iowait    %steal     %idle
01:43:57  EDT     all      0.00      0.00      0.25      0.00      0.00     99.75
01:43:59  EDT     all      0.00      0.00      0.00      0.00      0.00    100.00
01:44:01  EDT     all      0.00      0.00      0.25      0.00      0.00     99.75
01:44:03  EDT     all      0.00      0.00      0.25      0.25      0.00     99.50
01:44:05  EDT     all      0.00      0.00      0.00      0.00      0.00    100.00
Average:          all      0.00      0.00      0.15      0.05      0.00     99.80
[[email protected] ~]#

If the %I/O wait is more than zero for a longer period of time then we can consider there is some bottleneck in I/O system ( Hard disk or Network )

Example:2 Saving sar output to a file using -o

[[email protected] ~]# sar 2 5 -o /tmp/data > /dev/null 2>&1
[[email protected] ~]#

use “sar -f <file-name>” to display the reports.

[[email protected] ~]# sar -f /tmp/data


Example:3 Generating Memory Usage report using -r

-r option in the sar command is used to generate memory usage report.

[[email protected] ~]# sar -r 2 5


kbcommit & %commit is the overall memory used including RAM & Swap

Example:4 Generating Paging Statistics Report using -B

-B option in the sar command is used to display paging statistics.

[[email protected] ~]# sar -B 2 5


In the report majflts/s shows the major faults per second means number of pages loaded into the memory from disk (swap), if its value is higher then we can say that system is running of RAM.

%vmeff indicates the number of pages scanned per second, if it’s vaule is 100 % its is consider OK and when it is below 30 % then there is some issue with virtual memory. Zero value indicates that there is no page scanned during that time.

Example:5 Generating block device statistics report using -d

-d option in the sar command is used to display the block device statistics report. Using option -p (pretty-print) along with -d make the dev column more readable, example is shown below :

[[email protected] ~]# sar -d -p 2 4


Example:6 Generating Network statistic report using -n

-n option in the sar command is used to generate network statistic report. Below is the synatx :

# sar -n {keyword} or {ALL}

Following keywords can be used : DEV, EDEV, NFS, NFSD, SOCK, IP, EIP, ICMP, EICMP, TCP, ETCP, UDP, SOCK6, IP6, EIP6, ICMP6, EICMP6 & UDP6.

To generate all network statistic report use below command :

[[email protected] ~]# sar -n ALL


Example:7 Reading SAR log file using -f

As we have discuss that sar logs files are kept under /var/log/sa/saDD, using -f option in sar command we can read the log files.

[[email protected] ~]# sar -r -f /var/log/sa/sa26


Read Also: How to Sync Time in Linux Server using Chrony

Read Also20 ps Command Examples to Monitor Linux Processes

17 thoughts on “Generate CPU, Memory and I/O report using SAR command”

  1. Great tutorial. Next step could be to analyze sar report to get charts and aggregated data. For that we can follow ‘’

  2. Hi,

    I got results if I use “sar 2 6” . This works perfectly fine.

    But if I just say sar , it shows “LINUX RESTART” message.

    The file in /etc/cron.d/sysstat looks fine to me. Not sure whats the issue? Anyone has the same issue?


  3. With which command can I see or generate a file (report) only the use of a full day of use, only the CPU, RAM and Internet Consumption?

    It is to see the highest points of consumption.

    Thank you

  4. Hi,

    Thanks for all the explanation and examples.
    After playing around with it to generate reports over the previous day I came to the conclusion that when using the -f and -i option and -s 00:00:00 and -e 23:59:59 the last interval up to midnight is not reported on. In the example below the report goes up to 23:30:01. To me this means the period between 23:30 and 00:00(midnight) is not reported on.
    I assume that the time displayed in the report is the end of the interval reports on.
    Is there a way to show also the data for the last interval?
    Thanks in advance for any help

    [[email protected]] as $ sar -i 1800 -f /var/log/sa/sa01 -s 00:00:00 -e 23:59:59 -u -t
    Linux 3.10.0-1127.19.1.el7.x86_64 (server) 01/01/21 _x86_64_ (8 CPU)

    00:00:01 CPU %user %nice %system %iowait %steal %idle
    00:30:01 all 1.31 0.03 0.54 0.00 0.00 98.12
    01:00:01 all 1.29 0.03 0.54 0.00 0.00 98.14
    01:30:01 all 1.30 0.11 0.56 0.00 0.00 98.02
    . . .
    . . .
    22:00:01 all 1.30 0.03 0.54 0.00 0.00 98.12
    22:30:01 all 1.30 0.03 0.54 0.00 0.00 98.13
    23:00:01 all 1.33 0.03 0.50 0.00 0.00 98.14
    23:30:01 all 1.31 0.03 0.49 0.00 0.00 98.17
    Average: all 1.31 0.03 0.53 0.00 0.00 98.13

Leave a Reply

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