sar
Overview
The sar
(System Activity Reporter) command collects, reports, and saves system activity information. It provides historical and real-time system statistics.
Syntax
sar [options] [interval [count]]
Common Options
Option | Description |
---|---|
-A |
All statistics |
-b |
IO transfer rates |
-B |
Paging statistics |
-c |
Process creation |
-d |
Block device activity |
-n |
Network statistics |
-P |
Per-processor stats |
-q |
Queue length |
-r |
Memory utilization |
-S |
Swap space stats |
-u |
CPU utilization |
-v |
Kernel tables |
-w |
Task creation |
-W |
Swapping stats |
Output Types
Type | Description |
---|---|
CPU | Processor usage |
Memory | Memory stats |
Swap | Swap activity |
IO | Input/output |
Network | Network stats |
Process | Process stats |
Queue | System queue |
Disk | Disk activity |
Key Use Cases
- System monitoring
- Performance analysis
- Capacity planning
- Trend analysis
- Troubleshooting
Examples with Explanations
Example 1: CPU Usage
sar -u
CPU statistics
Example 2: Memory
sar -r
Memory statistics
Example 3: Network
sar -n DEV
Network interface stats
Common Usage Patterns
Real-time monitoring:
sar 1 5
Daily stats:
sar -f /var/log/sa/sa01
All stats:
sar -A
Additional Resources
Best Practices
- Regular collection
- Data retention
- Baseline creation
- Trend analysis
- Alert setup
Performance Analysis
- System load
- Resource usage
- Bottlenecks
- Capacity issues
- Performance trends
Troubleshooting
- System issues
- Resource constraints
- Performance problems
- Capacity limits
- Trend analysis
Data Collection
- Historical data
- Real-time stats
- System logs
- Performance metrics
- Resource usage