SAR command in Linux to monitor system performance

Photo of author
By Jay
— 4 min read
Photo of author
Written by
Photo of author
Verified by
Published On
— 4 min read

sar command in linux

The sar command in Linux is a powerful tool for monitoring system performance. It collects, reports, and saves various system activity metrics, including CPU usage, memory usage, I/O statistics, and more.

You can use sar command to view real-time performance data and historical data, which is invaluable for system administrators and developers in diagnosing performance issues and optimizing resource allocation.

Key Features of the SAR Command in linux

  • Resource Monitoring:
    • Monitors CPU usage, memory utilization, I/O devices, network activity, and disk usage.
    • Provides insights into process and thread allocation, battery performance, and file system statistics.
  • Data Collection:
    • Collects data at specified intervals and can save it for later analysis.
    • By default, it displays results on the screen, but you can save them to a file using the -o filename option.

How to install the SAR utility package by command.

# yum install sysstat* -y

Examples:

Using sar command to monitor system performance

The sar command is a useful tool for monitoring various system performance metrics in Linux. It can provide insights into CPU utilization, memory usage, disk usage, and more. Here are some examples of how to use the sar command to monitor system performance:

Monitoring CPU Utilization using sar command in linux:

# sar -p 2 10 

This command will display CPU utilization for every 2 seconds, up to 10 times.

Checking CPU Utilization on a Specific Day using sar command in linux:

# sar -p ALL -f /var/log/sa/sa25

This command will display the CPU utilization on the 25th day of the current month.

Checking CPU Utilization During Specific Time Frame using sar :

# sar -p ALL -f /var/log/sa/sa10 -s 07:00:00 -e 15:00:00 

This command will display the CPU utilization on the 10th day of the current month, from 7:00 to 15:00 hrs.

Monitoring Memory Utilization using sar command in linux:

# sar -r 2 10

This command will display memory utilization for every 2 seconds, up to 10 times.

Read Also | How to Manage DNF Software Modules in Linux: A Comprehensive Guide

Checking Memory Utilization on a Specific Day using sar command:

# sar -r -f /var/log/sa/sa14 

This command will display the memory utilization on the 14th day of the current month.

Checking Memory Utilization During Specific Time Frame using sar:

# sar -r -f /var/log/sa/sa10 -s 07:00:00 -e 15:00:00 

This command will display the memory utilization on the 10th day of the current month, from 7:00 to 15:00 hrs.

Monitoring Swap Utilization using sar command in linux:

# sar -S 2 10 

This command will display swap utilization for every 2 seconds, up to 10 times.

Checking Swap Utilization on a Specific Day using sar command:

# sar -S -f /var/log/sa/sa25 

This command will display the swap utilization on the 25th day of the current month.

Checking Swap Utilization During Specific Time Frame using sar command:

# sar -S -f /var/log/sa/sa10 -s 07:00:00 -e 15:00:00 

This command will display the swap utilization on the 10th day of the current month, from 7:00 to 15:00 hrs.

Monitoring Load Average using sar command in linux:

# sar -q 2 10 

This command will display the load average for every 2 seconds, up to 10 times.

Checking Load Average on a Specific Day using sar command in linux:

# sar -q -f /var/log/sa/sa14 

This command will display the load average on the 14th day of the current month.

Checking Load Average During Specific Time Frame using sar command in linux:

# sar -q -f /var/log/sa/sa10 -s 07:00:00 -e 15:00:00 

This command will display the load average on the 10th day of the current month, from 7:00 to 15:00 hrs.

Monitoring Paging Information using sar command in linux:

# sar -B 2 10 

This command will display the paging information for every 2 seconds upto 10 times.

Monitoring Disk Usage using sar command in linux:

# sar -d 2 10 

This command will display disk usage for every 2 seconds, up to 10 times.

Monitoring Power Management using sar command in linux:

# sar -m 2 10 

This command will display power management information for every 2 seconds, up to 10 times.

Monitoring Disk Input and Output Statistics using sar command in linux:

# sar -b 2 10 

This command will display disk input and output statistics for every 2 seconds, up to 10 times.

Read Also | Top 40 Linux commands every sysadmin should know


Conclusion

The sar command in linux is an essential tool for monitoring and analyzing system performance in Linux. It helps in identifying bottlenecks and optimizing resource usage, making it a critical component for effective system administration. By utilizing its various options, you can gain comprehensive insights into your system’s performance metrics.

Reference: https://man7.org/linux/man-pages/man1/sar.1.html

Related Posts


About Author

Photo of author

Jay

I specialize in web development, hosting solutions, and technical support, offering a unique blend of expertise in crafting websites, troubleshooting complex server issues, and optimizing web performance. With a passion for empowering businesses and individuals online, I provide in-depth reviews, tech tutorials, and practical guides to simplify the digital landscape. My goal is to deliver clear, reliable, and insightful content that helps readers make informed decisions and enhance their online presence.

Leave a Comment