Monitoring system resources helps you understand performance and identify bottlenecks before they become problems.
CPU Monitoring
top # Interactive CPU/memory viewer
htop # Enhanced version
vmstat 1 # Virtual memory stats
mpstat 1 # CPU statistics
Memory Monitoring
free -h # Memory usage
cat /proc/meminfo # Detailed memory info
ps aux --sort=-%mem # Processes by memory
Disk I/O
iostat -x 1 # I/O statistics
iotop # I/O by process
df -h # Disk space
du -sh * # Directory sizes
Network Monitoring
netstat -tulpn # Network connections
ss -tulpn # Modern alternative
iftop # Network traffic by host
nethogs # Network by process
System Load
uptime # Load averages
w # Who and load
cat /proc/loadavg # Load averages
Process Monitoring
ps aux --sort=-%cpu # By CPU usage
ps aux --sort=-%mem # By memory
pgrep -f pattern # Find process IDs
Continuous Monitoring
# Watch command
watch -n 1 'df -h'
# Custom monitoring script
while true; do
echo "$(date): $(free -h | grep Mem)"
sleep 5
done
Performance Tuning
- Identify resource bottlenecks
- Optimize based on monitoring data
- Set up alerts for thresholds
- Document baseline performance
Regular monitoring helps maintain system health and performance.