sar
Overview
The sar
(System Activity Reporter) command collects, reports, and saves system activity information. It provides comprehensive system performance monitoring capabilities.
Syntax
sar [options] [interval [count]]
Common Options
Option | Description |
---|---|
-b |
I/O and transfer rate statistics |
-B |
Paging statistics |
-d |
Block device activity |
-n |
Network statistics |
-P |
Per-processor statistics |
-r |
Memory utilization |
-S |
Swap space utilization |
-u |
CPU utilization |
-v |
Process, inode, file tables |
-w |
System switching activity |
-A |
All statistics |
-f file |
Extract records from file |
-o file |
Save records to file |
Key Use Cases
- Performance monitoring
- System analysis
- Resource tracking
- Capacity planning
- Troubleshooting
Examples with Explanations
Example 1: CPU Usage
sar -u 2 5
Show CPU stats every 2 seconds, 5 times
Example 2: Memory Stats
sar -r
Show memory utilization
Example 3: Network Stats
sar -n DEV
Show network interface statistics
Understanding Output
CPU statistics: - %user: User time - %nice: Nice time - %system: System time - %iowait: I/O wait time - %steal: Time stolen by virtualization - %idle: Idle time
Memory statistics: - kbmemfree: Free memory - kbmemused: Used memory - %memused: Memory used percentage - kbbuffers: Memory used as buffers - kbcached: Memory used as cache
Common Usage Patterns
Daily monitoring:
sar -A > report.txt
Network analysis:
sar -n ALL 1
Historical data:
sar -f /var/log/sa/sa01
Performance Analysis
- System resource usage
- Performance bottlenecks
- Resource trends
- Capacity issues
- Historical patterns
Additional Resources
Best Practices
- Regular data collection
- Historical analysis
- Trend monitoring
- Alert thresholds
- Documentation
Data Collection
- Automated collection
- Data retention
- Report generation
- Analysis tools
- Storage management