nmon
Performance monitor for Linux with data capture.
Official WebsiteFeatures
Installation
apt install nmondnf install nmonWhy Use nmon?
Comprehensive Performance Data
Monitor CPU, memory, disk I/O, network, filesystems, and process information all in one interface.
Data Capture & Export
Capture performance data to CSV files for historical analysis, trend analysis, and capacity planning.
Interactive Monitoring
Real-time interactive display with customizable views and the ability to drill down into specific metrics.
Lightweight & Efficient
Low overhead monitoring tool perfect for production environments and continuous monitoring scenarios.
Installation
# Ubuntu/Debian
sudo apt install nmon
# Fedora/RHEL
sudo dnf install nmon
# Arch Linux
sudo pacman -S nmon
# CentOS 7
sudo yum install nmon
# Verify installation
nmon -hBasic Usage
# Start nmon in interactive mode
nmon
# Monitor specific interface (e.g., eth0)
nmon -i eth0
# Record performance data to CSV
nmon -f -s 10 -c 120
# Writes data every 10 seconds for 120 iterations (20 minutes)
# Record with custom interval
nmon -f -s 5 -c 240
# Every 5 seconds for 240 iterations (20 minutes)
# Record specific metrics
nmon -f -N
# Record only network metrics
# Specify output directory
nmon -f -d /tmp/monitoring/Key Shortcuts & Commands
| Key | Function |
|---|---|
c | Show CPU statistics |
m | Show memory statistics |
d | Show disk I/O statistics |
n | Show network statistics |
p | Show process statistics |
f | Show filesystem statistics |
h | Show help |
q | Quit nmon |
Data Capture & Analysis
Recording Performance Data
nmon can capture performance data to CSV format for later analysis using spreadsheet applications or analysis tools.
# Basic recording: every 30 seconds for 24 hours
nmon -f -s 30 -c 2880
# High frequency recording: every 1 second for 1 hour (use for detailed analysis)
nmon -f -s 1 -c 3600
# Specify output filename
nmon -f -n -s 10 -c 360
# Creates file like: hostname_120126_1300.nmon
# Check recorded files
ls -la *.nmon
# Generate reports from collected data
# Using nmon analyzer (requires separate tool):
# Visit: http://www.ibm.com/developerworks/wikis/display/nmon/nmon_analyser_v58+-+WorkbookAdvanced Recording Options
# Record only specific metrics
nmon -f -s 5 -c 240 -C # CPU only
nmon -f -s 5 -c 240 -M # Memory only
nmon -f -s 5 -c 240 -D # Disk only
nmon -f -s 5 -c 240 -N # Network only
# Record top processes
nmon -f -s 10 -c 360 -P
# Capture to specific output file
nmon -f -n -s 30 -c 2880 -o /var/log/monitoring/Common Use Cases
1. Real-Time System Monitoring
# Start interactive monitoring
nmon
# Navigate using interactive keys:
# Press 'c' for CPU, 'm' for memory, 'd' for disk, 'n' for network2. Continuous Data Capture for Analysis
# Run in background: capture every 2 minutes for 7 days
nmon -f -s 120 -c 5040 &
# Or with cron job for periodic monitoring:
# Add to crontab: 0 * * * * nmon -f -s 300 -c 288 -o /var/log/nmon/
# Check running nmon processes
ps aux | grep nmon3. Capacity Planning & Trend Analysis
# Collect baseline data for a week
nmon -f -s 300 -c 2016 -o /data/baseline/
# Analyze peak usage patterns
# Use Excel or gnuplot with the generated CSV files
# Compare different time periods
# Run nmon at regular intervals and compare the output files4. Troubleshooting Performance Issues
# Capture detailed data during issue occurrence
# Start recording before issue appears:
nmon -f -s 5 -c 600
# Then trigger or wait for the issue to occur
# Analyze the CSV data afterward to find correlations
# Monitor specific processes
# Use 'p' key in interactive mode to show top processesTips
1. Choose Appropriate Sampling Intervals
For real-time troubleshooting, use 1-5 second intervals. For long-term trending, use 5-minute or longer intervals to reduce file sizes.
2. Manage Data Storage
Collected CSV files can grow large. Use compression or archive old files regularly. Consider storing data on a dedicated monitoring server.
3. Use nmon Analyzer for Visualization
IBM provides nmon analyzer (Excel macro) to convert CSV data into charts and graphs. This makes trend analysis much easier.
4. Background Monitoring Setup
Run nmon data collection in the background using nohup or as a cron job for continuous monitoring without occupying a terminal session.
5. Monitor Multiple Systems
Use nmon on multiple servers and centralize the CSV files for comparative analysis across your infrastructure.