sar
sar
The sar
command in Linux is used to collect, report, and save system activity information. It stands for "System Activity Report" and provides a wide range of metrics about system performance over time. Here’s a detailed explanation of how to use sar
and what information it provides:
Usage of sar
sar
Basic Usage
To use sar
, open a terminal and simply type:
By default, sar
displays CPU utilization statistics for the current day.
Options and Output
sar
provides various options to specify the type of data and time intervals to report:
Data Collection
-u
: Report CPU utilization.-r
: Report memory utilization.-b
: Report I/O and transfer rate statistics.-n DEV
: Report network statistics.-q
: Report queue length and load averages.-A
: Report all available data.
Time Intervals
-f <file>
: Read data from a specified file.-s <HH:MM:SS>
: Start time (e.g.,-s 08:00:00
).-e <HH:MM:SS>
: End time (e.g.,-e 17:00:00
).
Output Control
-o <file>
: Save output to a file.-n <interval>
: Set reporting interval in seconds (e.g.,-n 10
for every 10 seconds).
Example Usage
CPU Utilization
This command displays CPU utilization statistics every 1 second, 5 times.
Memory Utilization
This command reports memory utilization statistics.
I/O Statistics
This command reports I/O and transfer rate statistics.
Use Cases
Performance Monitoring:
sar
is useful for monitoring system performance metrics such as CPU, memory, disk I/O, and network activity over time.Resource Management: Helps in identifying bottlenecks and optimizing system resources based on historical performance data.
Capacity Planning: Provides insights into resource usage trends, aiding in capacity planning for future infrastructure needs.
Conclusion
sar
is a powerful tool for system administrators and users interested in monitoring and analyzing system performance metrics on Linux. By leveraging its extensive options and capabilities, users can gain valuable insights into system behavior and effectively manage system resources.
**
help
Last updated