Linux System Monitoring
As a DevOps engineer, you need to know what is happening on your servers at all times. When a page loads slowly, when an API starts timing out, when a deploy goes sideways — the first question is always “what is the server doing right now?” Monitoring tools answer that question. Think of them as the dashboard gauges in a car: you can drive without looking, but you will not see the engine overheating until it is too late.1. Real-Time Monitoring
top / htop
The task manager of Linux. Shows CPU, memory, and running processes in real time.
- Load Average: Three numbers showing system load over 1, 5, and 15 minutes. The rule of thumb: if load average exceeds the number of CPU cores, the system is overloaded. A 4-core machine with load 6.0 has processes waiting in line for CPU time.
- CPU bars: Green is user-space processes (your apps). Red is kernel work (system calls, I/O). Blue is low-priority (nice) processes. If you see solid red bars, your system is spending too much time in the kernel, often a sign of heavy I/O or too many context switches.
- Memory: Green is actively used. Yellow/blue is cache and buffers — this is memory that Linux is using intelligently to speed up disk reads, and it will be freed immediately when needed. Do not panic if “used” looks high — look at the “available” number instead.
free
Check memory usage at a glance.
df and du - Disk Space
2. Resource Analysis
vmstat (Virtual Memory Statistics)
vmstat gives you a one-line summary of CPU, memory, I/O, and scheduling, updated at whatever interval you choose. It is the fastest way to determine whether your bottleneck is CPU, memory, or disk.
- r (runnable): Processes waiting for CPU time. If consistently higher than your CPU core count, you are CPU-bound.
- b (blocked): Processes in uninterruptible sleep (usually waiting for I/O). If this is consistently above zero, you have an I/O bottleneck.
- si/so (swap in/out): Any non-zero value means the system is swapping — actively moving memory pages between RAM and disk. This is an emergency for performance-sensitive workloads.
- wa (wait): Percentage of CPU time spent waiting for I/O. Above 10-20% usually indicates a disk or network bottleneck.
- us/sy/id: User CPU, system CPU, and idle. High
sy(system) can indicate too many context switches or heavy I/O.
iostat (Input/Output Statistics)
When vmstat suggests an I/O bottleneck, iostat tells you which disk and how severe.
- await: Average time (ms) for I/O requests. If this is climbing into the hundreds, your disk cannot keep up.
- %util: Percentage of time the disk was busy. Above 80% means the disk is saturated. At 100%, new I/O requests are queuing up and wait times will spike.
- r/s and w/s: Reads and writes per second — helps you understand the I/O pattern (is it read-heavy or write-heavy?).
sar - Historical Data
Unlike top and vmstat which show the present, sar records and displays historical performance data. It runs continuously in the background (via sysstat) and lets you look back at what happened during last night’s incident.
3. Network Monitoring
ss - Socket Statistics
iftop - Bandwidth by Connection
Quick Network Diagnostics
4. Log Management
Logs are the source of truth for what happened and when. When monitoring tells you something is wrong, logs tell you what is wrong.journalctl (Systemd Logs)
Systemd captures stdout and stderr from every service it manages. journalctl is how you search and filter those logs.
/var/log - Traditional Log Files
Not everything uses journald. Many applications write to files in /var/log directly.
Log Rotation
Without rotation, log files grow until they fill the disk.logrotate handles this automatically.
5. The Performance Investigation Workflow
When something is slow, follow this systematic approach instead of guessing:Key Takeaways
- Use htop for a quick interactive overview of CPU, memory, and processes
- Use vmstat to determine whether your bottleneck is CPU, memory, or I/O — it is the fastest single-command diagnosis
- Use iostat when vmstat points to an I/O problem, to identify the saturated disk
- Use free -h and look at the “available” column, not “free” — cached memory is available memory
- Use journalctl to search and filter systemd service logs, especially during incidents
- A full disk silently breaks everything — monitor disk usage and configure log rotation
- Follow a systematic workflow (load, CPU/IO split, process, deep dive) instead of guessing
Next: Security Hardening →