How to install and configure SAR on CentOS/RHEL

System Activity Reporter (SAR) is an important tool that helps system administrator to get a review of the server machine with status of different critical metrics at different points of time. Using sar you can monitor performance of different Linux subsystems (CPU, Memory, I/O..) in real time. The sar command extracts and write to standard output records previously saved in a file.

sar

This article explains how to install and configure sysstat package.

Install SAR

You can easily install it in your system through YUM. Use following command to install SAR.

# yum install sysstat

Check SAR

Once installed, verify the sar version using following command:

# sar -V
sysstat version 9.0.4
(C) Sebastien Godard (sysstat  orange.fr)

Collect the statistics using cron job

Create sysstat file under /etc/cron.d directory that will collect the historical sar data.

# cat /etc/cron.d/sysstat
# Run system activity accounting tool every 10 minutes
*/10 * * * * root /usr/lib64/sa/sa1 1 1
# 0 * * * * root /usr/lib64/sa/sa1 600 6 &
# Generate a daily summary of process accounting at 23:53
53 23 * * * root /usr/lib64/sa/sa2 -A
  • So the first cron entry will run every 10 minutes which will call the sadc utility and collect system stats and store it in a binary file.
  • And the second cron entry will dump all the contents of that binary file into another text file.

By default 7 days statistics, So you can modify that HISTORY entry easily by editing the file.

# cat /etc/sysconfig/sysstat
# How long to keep log files (in days).
# If value is greater than 28, then log files are kept in
# multiple directories, one for each month.
HISTORY=28

By default all the statistics will save /var/log/sa location.

# cd /var/log/sa

Reference Articles:
How of use SAR command for system monitoring in CentOS/RHEL
Some more command to use SAR command for system monitoring

No Responses

Leave a Reply

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

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.