Use sar and kSar to discover Linux performance bottlenecks

The sar command is a powerful tool used to collect, report, and save activity information for UNIX/Linux systems. It stores the selected performance counters in the operating system's /var/log/sa/sadd file. From this data, you can gain valuable insights into your server's performance, such as:

  • CPU utilization
  • Memory page and usage statistics
  • Network I/O and transmission metrics
  • Process creation activity
  • Block device activities
  • Interrupts per second, among others.

The output of the sar command can help identify potential bottlenecks in your server's performance. However, interpreting this data manually can be challenging, which is why tools like kSar are useful. kSar transforms the raw sar output into visual, time-based charts that are much easier to understand.

The sysstat package includes several utilities, such as sar, sa1, and sa2. These tools are essential for monitoring system performance on Linux systems. Here’s a brief overview of each:

  • sar: Displays collected system activity data.
  • sa1: Collects and saves system activity data in binary format for later analysis.
  • sa2: Generates daily reports in the /var/log/sa directory.

The sadc utility (System Activity Data Collector) is called by sa1 and sa2 to log data. The scripts are typically located in these directories:

  • /usr/lib64/sa/sa1 (for 64-bit systems) or /usr/lib/sa/sa1 (for 32-bit systems)
  • /usr/lib64/sa/sa2 (for 64-bit systems) or /usr/lib/sa/sa2 (for 32-bit systems)

To install sar on a CentOS/RHEL-based system, use the following command:

yum install sysstat

Once installed, you can configure the sysstat package by editing the /etc/sysconfig/sysstat file. This file allows you to specify how long the logs should be retained (up to one month):

HISTORY=28

The default cron job for sysstat is located at /etc/cron.d/sysstat. You can modify this file to customize how often data is collected. For example:

*/10 * * * * root /usr/lib64/sa/sa1 -I -d
53 23 * * * root /usr/lib64/sa/sa2 -A

For CentOS/RHEL 7.x systems, you may need to pass additional options like -S DISK to collect disk-related data.

After installation, enable and start the sysstat service:

systemctl enable sysstat
systemctl start sysstat.service

To view real-time CPU usage, run:

sar -u 3 10

Other common commands include:

  • sar -c 3 10: View process creation statistics.
  • sar -b 3 10: View I/O and transfer rates.
  • sar -d 3 10: View block device activity.
  • sar -n DEV 3 10: View network device statistics.

kSar is a Java-based tool that provides a graphical interface to visualize sar data. It supports various formats, including PDF, JPG, PNG, and CSV. You can load data from local files, remote servers, or directly from the command line.

To download and run kSar, visit its official GitHub page and execute:

wget https://github.com/vlsi/ksar/releases/download/v5.2.4-snapshot-652bf16/ksar-5.2.4-SNAPSHOT-all.jar
java -jar ksar-5.2.4-SNAPSHOT-all.jar

kSar offers an intuitive way to analyze sar data, making it ideal for administrators who prefer visual insights over command-line output.

In case of CPU bottlenecks, you can optimize performance by:

  • Disabling unnecessary background processes.
  • Scheduling resource-heavy tasks during off-peak hours.
  • Using the top, ps, and renice commands to manage processes.
  • Binding specific applications to certain CPUs using taskset.
  • Upgrading hardware if necessary.

Another alternative to kSar is isag, which also provides graphical views of sar data but with fewer features compared to kSar.

Digital Load Cells

Digital Laod Cells,Small Load Cell,Hardy Load Cells,Scaime Load Cell

Xiaogan Yueneng Electronic Technology Co., Ltd. , https://www.xgsensor.com