← Back to Linux

How to Monitor Linux Server Performance: Tools and Commands

Linux server performance monitoring requires understanding key metrics—CPU utilization, memory usage, disk I/O, and network throughput—and knowing which tools to use. The most effective administrators combine built-in commands like top, vmstat, and iostat with persistent monitoring solutions.

Essential Monitoring Commands

The top Command

top is your starting point. It's interactive, real-time, and available on every Linux system. Press Shift+M to sort by memory usage.

top
top -b -n 1  # single snapshot, non-interactive

The vmstat Command

vmstat reports virtual memory statistics. High wa values indicate disk I/O bottlenecks.

vmstat 5  # update every 5 seconds

The iostat Command

For disk performance, iostat shows per-disk statistics including I/O operations, throughput, and wait times.

iostat -x 1

The sar Command

sar collects and reports historical performance data. Unlike top, it maintains a running log ideal for trend analysis.

sar -u 1 5     # CPU utilization
sar -r         # Memory and swap
sar -n DEV     # Network device stats

Monitoring Database-Specific Metrics

For MySQL, query the PROCESSLIST to monitor active connections:

SHOW PROCESSLIST;
SHOW STATUS WHERE variable_name IN ('Threads_connected', 'Threads_cached');

For PostgreSQL:

SELECT datname, count(*) FROM pg_stat_activity GROUP BY datname;

Best Practices