Title: Use sar
Course: CIS 208: Linux/UNIX III: Intermediate System Administration, Networking, and Security ~ For IGNITE Review > Section: Learning Modules

Use sar

The sysstat package is installed by default on Red Hat derivative systems, and it includes the cronjobs to gather information which is accessed by sar.
Here is sample output of the sar command with no options.  Note that it provides CPU information for the current day at 10 minute intervals.

[root@tinman ~]# sar | head
Linux 2.6.32-504.1.3.el6.x86_64 (tinman.carltm.com)     11/25/2014      _x86_64_(2 CPU)

12:00:01 AM     CPU     %user     %nice   %system   %iowait    %steal     %idle
12:10:01 AM     all        0.02        0.00     0.01          0.03        0.00         99.94
12:20:01 AM     all        0.01        0.00     0.00          0.02        0.00         99.97
12:30:01 AM     all        0.01        0.00     0.01          0.02        0.00         99.96
12:40:01 AM     all        0.01        0.00     0.01          0.01        0.00         99.98
12:50:01 AM     all        0.01        0.00     0.00          0.02        0.00         99.96
01:00:01 AM     all        0.01        0.00     0.01          0.02        0.00         99.97
01:10:01 AM     all        0.01        0.00     0.01          0.03        0.00         99.95
[root@tinman ~]#

Adding the "-q" option shows the load average.

[root@tinman ~]# sar -q | head
Linux 2.6.32-504.1.3.el6.x86_64 (tinman.carltm.com)     11/25/2014      _x86_64_(2 CPU)

12:00:01 AM   runq-sz  plist-sz   ldavg-1   ldavg-5  ldavg-15
12:10:01 AM         0       118      0.00       0.00       0.00
12:20:01 AM         0       118      0.00       0.00       0.00
12:30:01 AM         0       119      0.00       0.00       0.00
12:40:01 AM         0       118      0.00       0.00       0.00
12:50:01 AM         0       118      0.00       0.00       0.00
01:00:01 AM         0       118      0.00       0.00       0.00
01:10:01 AM         0       118      0.00       0.00       0.00
[root@tinman ~]#

Adding the "-r" option shows memory utilization.

[root@tinman ~]# sar -r | head
Linux 2.6 32-504. 1.3 el6.x86_64 (tinman.carltm.com) 11/25/2014 _x86_64_(2 CPU)

12:00:01 AM   kbmemfree   kbmemused   %memused   kbbuffers   kbcached   kbcommit   %commit
12:10:01 AM   396464         623707           61.14             61348       360228      192496       6.18
12:20:01 AM   396580         623588           61.13             61352       360232      192496       6.18
12:30:01 AM   396472         623696           61.14             61368       360232      192496       6.18
12:40:01 AM   396472         623696           61.14             61372       360236      192496       6.18
12:50:01 AM   396348         623820           61.15             61376       360236      192469       6.18
01:00:01 AM   396340         623828           61.15             61380       360240      192496       6.18
01:10:00 AM   396464         623704           61.14             61388       360244      192496       6.18
[root@tinman ~]#

Adding the "-W" option shows swapping information.

[root@tinman ~]# sar -W | head
Linux 2.6.32-504.1.3.el6.x86_64 (tinman.carltm.com)     11/25/2014      _x86_64_(2 CPU)

12:00:01 AM  pswpin/s    pswpout/s
12:10:01 AM      0.00         0.00
12:20:01 AM      0.00         0.00
12:30:01 AM      0.00         0.00
12:40:01 AM      0.00         0.00
12:50:01 AM      0.00         0.00
01:00:01 AM      0.00         0.00
01:10:01 AM      0.00         0.00
[root@tinman ~]#

Adding the "-b" option show input/output operations.

[root@tinman ~]# sar -b | head
Linux 2.6.32-504.1.3.el6.x86_64 (tinman.carltm.com)     12/25/2014   _x86_64_(2 CPU)

12:00:01 AM      tps       rtps       wtps       bread/s       bwrtn/s
12:10:01 AM      0.15     0.00       0.15        0.00            1.41
12:20:01 AM      0.07     0.00       0.07        0.00            0.72
12:30:01 AM      0.11     0.00       0.11        0.00            1.09
12:40:01 AM      0.08     0.00       0.08        0.00            0.72
12:50:01 AM      0.06     0.00       0.06        0.00            0.59
01:00:01 AM      0.07     0.00       0.07        0.00            0.72
01:10:01 AM      0.13     0.00       0.13        0.00            1.28
[root@tinman ~]#

The /var/log/sa directory stores data from previous days.  The files all end with two digits, which is the day of the month when the data was collected.  Files beginning with "sa" are binary and those starting with "sar" are human readable.  For example, to view the swap data for the third of the month, use "sar -W -f /var/log/sa/sa03".