Linux Static Performance Tools Cheatsheet
Table of Contents
- System Architecture Overview
- Performance Analysis Tools by Layer
- Hardware Layer Tools
- Operating System Layer Tools
- Application Layer Tools
- Detailed Tool Reference
System Architecture Overview
The Linux system architecture consists of multiple layers, each with specific performance monitoring and analysis tools. Here's a detailed breakdown of each layer and its components:
Hardware Layer
- CPUs
- DRAM
- I/O Controllers
- Network Controllers
- Storage Devices
Operating System Layer Components
- Device Drivers
- Block Device
- Network Device
- Virtual Memory
- File Systems
- TCP/UDP
- IP Stack
- System Call Interface
- Scheduler
- Clock Source
Application Layer
- Applications
- System Libraries
- VFS (Virtual File System)
- Sockets
Performance Analysis Tools by Layer
Hardware Level Tools
CPU Analysis Tools
# CPU information and statistics
/proc/cpuinfo # Detailed CPU information
cpuid # CPU identification and features
lscpu # CPU architecture information
cpu-x # CPU identification tool
# CPU Performance Monitoring
numact1 # NUMA topology and statistics
lstopo # Hardware topology viewer
dmidecode # DMI table decoder
Memory Analysis
# Memory statistics and information
free -m # Memory usage overview
vmstat # Virtual memory statistics
dmidecode # Memory hardware information
# Memory Performance Tools
lstopo # Memory topology visualization
numact1 # NUMA memory statistics
Operating System Level Tools
File System Tools
# Disk and Filesystem Analysis
df -h # Filesystem usage
lsblk # Block device information
blockdev # Block device operations
smartctl # SMART disk monitoring
fdisk -l # Disk partition information
lsusb # USB device information
# Advanced Storage Analysis
mdadm # RAID management and monitoring
dmesg # Storage device messages
Network Analysis Tools
# Basic Network Tools
ip route # IP routing table
tc # Traffic control
ethtool # Network interface settings
iwconfig # Wireless interface configuration
lldptool # Link Layer Discovery Protocol tool
# Network Statistics
netstat # Network statistics
ss # Socket statistics
ip # IP configuration and statistics
System Call Interface Tools
# System Call Monitoring
strace # System call tracer
ltrace # Library call tracer
syscall # System call information
sysctl # Kernel parameter configuration
Scheduler Analysis
# Scheduler Tools
schedtool # Process scheduler configuration
chrt # Real-time scheduler priorities
taskset # CPU affinity configuration
Application Level Tools
Process Analysis
# Process Monitoring
top # Process activity monitoring
htop # Interactive process viewer
ps # Process status
pstree # Process hierarchy view
System Library Analysis
# Library Tools
ldd # Shared library dependencies
ldconfig # Library path configuration
ld # Link editor for object files
Detailed Tool Reference
System Information Tools
sysctl
# View all system parameters
sysctl -a
# View specific parameter
sysctl kernel.hostname
# Modify parameter
sysctl -w kernel.hostname=newname
# Load settings from file
sysctl -p /etc/sysctl.conf
dmesg
# View kernel messages
dmesg
# Clear kernel ring buffer
dmesg -c
# Show human-readable timestamps
dmesg -T
# Follow new messages
dmesg -w
Storage Performance Tools
smartctl
# Check disk health
smartctl -a /dev/sda
# Run short self-test
smartctl -t short /dev/sda
# Show test results
smartctl -l selftest /dev/sda
# Enable SMART
smartctl -s on /dev/sda
iostat
# Basic I/O statistics
iostat
# Extended statistics
iostat -x
# Device utilization
iostat -d
# Updates every 2 seconds
iostat 2
Network Performance Tools
ethtool
# Show interface settings
ethtool eth0
# Show interface statistics
ethtool -S eth0
# Set interface speed
ethtool -s eth0 speed 1000
# Check link status
ethtool -i eth0
tc (Traffic Control)
# Show queueing discipline
tc qdisc show
# Add rate limiting
tc qdisc add dev eth0 root tbf rate 1mbit burst 32kbit latency 400ms
# Show filter rules
tc filter show dev eth0
# Delete all rules
tc qdisc del dev eth0 root
Process Management Tools
schedtool
# Show process scheduler info
schedtool -p 1234
# Set SCHED_FIFO policy
schedtool -F -p 50 1234
# Set CPU affinity
schedtool -a 0-3 1234
# Show all scheduler policies
schedtool -h
numact1
# Show NUMA topology
numactl --hardware
# Run command on specific node
numactl --membind=0 command
# Show NUMA statistics
numactl --show
# Set memory policy
numactl --preferred=0 command
Virtual Memory Analysis
vmstat
# Memory statistics
vmstat
# Detailed memory info
vmstat -s
# Active/inactive memory
vmstat -a
# Disk statistics
vmstat -d
Advanced Analysis Tools
SystemTap
# Create simple probe
stap -e 'probe syscall.open { println(execname()) }'
# Monitor file operations
stap -e 'probe vfs.read { printf("%s read %d bytes\n", execname(), count) }'
# Track process creation
stap -e 'probe process.begin { printf("%s started\n", execname()) }'
perf
# CPU performance counters
perf stat command
# System-wide sampling
perf record -a sleep 10
# Show recorded data
perf report
# Live performance monitoring
perf top
Hardware Management
dmidecode
# Show all hardware info
dmidecode
# Show memory info
dmidecode -t memory
# Show CPU info
dmidecode -t processor
# Show system info
dmidecode -t system
Volume Management Tools
MegaCli
# Show RAID configuration
MegaCli -CfgDsply -aALL
# Check battery status
MegaCli -AdpBbuCmd -aALL
# Show drive information
MegaCli -PDList -aALL
# Check rebuild status
MegaCli -PDRbld -ShowProg -physdrv[252:2] -aALL
Performance Monitoring Best Practices
- Regular Monitoring
- Set up baseline measurements
- Monitor trends over time
-
Create alerts for anomalies
-
Resource Usage
- Track CPU utilization
- Monitor memory consumption
- Watch I/O patterns
-
Analyze network traffic
-
System Health
- Check system logs
- Monitor hardware status
- Track error rates
-
Verify service status
-
Performance Optimization
- Identify bottlenecks
- Tune system parameters
- Optimize application settings
- Balance resource allocation
Common Performance Issues and Solutions
- CPU Bottlenecks
- Use
top
andhtop
to identify high CPU processes - Check process priorities with
nice
andrenice
- Monitor CPU scheduling with
schedtool
-
Analyze system load with
uptime
-
Memory Problems
- Check memory usage with
free
andvmstat
- Monitor swap usage
- Analyze memory leaks
-
Tune kernel memory parameters
-
Disk I/O Issues
- Monitor disk activity with
iostat
- Check disk health with
smartctl
- Analyze I/O patterns with
iotop
-
Optimize filesystem parameters
-
Network Performance
- Monitor bandwidth with
iftop
- Analyze connections with
netstat
- Check network errors with
ethtool
- Tune network parameters with
sysctl
Quick Reference Commands
# System Overview
top # Process activity
htop # Interactive process viewer
uptime # Load average
dmesg # Kernel messages
# Memory Analysis
free -m # Memory usage
vmstat # Virtual memory stats
pmap # Process memory map
smem # Memory reporting
# Disk Operations
iostat # I/O statistics
iotop # I/O monitoring
fdisk -l # Disk partitions
df -h # Filesystem usage
# Network Analysis
netstat # Network statistics
ss # Socket statistics
iftop # Network bandwidth
tcpdump # Packet analysis
# Process Management
ps aux # Process status
pstree # Process tree
nice # Process priority
renice # Change priority
# System Information
uname -a # System information
lscpu # CPU information
lsblk # Block devices
lspci # PCI devices
Additional Resources
- Documentation
- Man pages for each tool
- Linux kernel documentation
- Distribution-specific guides
-
Tool-specific documentation
-
Performance Tuning Guides
- Red Hat Performance Tuning Guide
- Ubuntu Server Guide
- Linux Performance website
-
Kernel documentation
-
Monitoring Tools
- Nagios
- Zabbix
- Prometheus
-
Grafana
-
Training Resources
- Linux Foundation courses
- Distribution certification programs
- Online tutorials
- Community forums