Bobcares

wesupport

CLIENT AREACall Us 1-800-383-5193
Bobcares

wesupport

Call Us 1-800-383-5193
Bobcares

wesupport

Call Us 1-800-383-5193

Need help?

Our experts have had an average response time of 13.52 minutes in October 2021 to fix urgent issues.

We will keep your servers stable, secure, and fast at all times for one fixed price.

EC2: Configure SAR to monitor performance metrics – How to do

by | Jul 11, 2021

Wondering how to Configure SAR to monitor performance metrics in EC2 instance? We can help you!

System Activity Reporter (SAR) is one of the monitoring tools that allow us to collect performance data as needed for CPU, memory, and I/O usage. We can set up SAR to get historical metrics.

Here at Bobcares, we handle requests from our customers to configure similar issues as a part of our Server Management Services.

Today let’s see how our Support Engineers configure SAR on EC2 instances of our customers.

How to Configure SAR to monitor performance metrics in EC2

Now we will see the steps that our Support Engineers follow to configure SAR:

Steps to configure:

1. Firstly, we have to install the EPEL release package for RHEL 7 using the amazon-linux-extras command:

sudo amazon-linux-extras install epel

2. Then we can install the monitoring tools using the following command:

sudo yum -y install sysstat atop --enablerepo=epel

3. Also we can change the log collection interval using the following command:

>sudo sed -i 's/^LOGINTERVAL=600.*/LOGINTERVAL=60/' /etc/sysconfig/atop
sudo sed -i -e 's|*/10|*/1|' -e 's|every 10 minute

Configuration overview

We can view and edit the configuration file, /etc/sysconfig/sysstat, after installation.

The configuration file contains the following default values:

HISTORY=28: This parameter determines how long SAR keeps performance log files. The default value is 28 days.

COMPRESSAFTER=31: This parameter determines after how many days SAR compresses files. The default value is 31 days. Note: If we set the configuration file to keep log files longer than 28 days, then SAR keeps each month's files in a separate directory.

SA_DIR=/var/log/sa: SAR saves log files to this location.

ZIP="bzip2": This is the default zip file containing compressed log files. Ensure to enable compression if we wish to keep files for more than 31 days. Compressed files occupy the least possible space on the disk.

The sadc (system activity data collector) operation performs data collection. Furthermore, the collected data is written in text format and contained in the sar## files in the /var/log/sa/ directory.

Set data collection intervals

The following command helps us to view the scripts that the SAR utility currently runs in crontab to generate data:

cat /etc/cron.d/sysstat

By default, SAR generates data every 10 minutes. However, if we wish to change the interval we can do the following:

1. Firstly, open  /etc/cron.d/sysstat file using the following command:

vim /etc/cron.d/sysstat

2. To change the run time from 10 to 5 we can do the following

@reboot /usr/lib64/sa/sa1 --boot
 */5 * * * * root /usr/lib64/sa/sa1 1 1

Commands to generate performance reports as needed

CPU usage report

We can use the sar command to generate a CPU usage data report. The following example command generates a usage data report 5 times every 2 seconds:

sar 2 5 -P 0

Memory statistics report

Use the -r option to generate a memory statistics report. The following example command generates memory statistics 5 times every 2 seconds:

sar -r 2 5

Block device statistics report

Use the -d option to generate a block device statistics report. The following example command generates block device statistics 5 times every 2 seconds:

sar -d -p 2 5

Network statistics report

Use the -n option to generate a network statistics report. We can generate statistics for specific entities, such as TCP, UDP, NFS, etc. or ALL as shown in the following examples:

sar -n TCP 2 5
sar -n UDP 2 5
sar -n ALL 2 5

To Read the most recent log file

Running sar commands extracts details from the most recent log file in /var/log. To read the complete file, use the -f option, as shown in the following example:

sar -f /var/log/sa

[Need assistance? We can help you]

Conclusion

To conclude, we saw the steps that our Support Techs follow to Configure SAR to monitor performance metrics on EC2 instances. Also we some of the basic commands of sar.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

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

Categories

Tags