System Resource Monitoring

Monitoring system resources in real-time lets you diagnose performance problems, understand baseline behavior, and catch issues before they become outages. Ubuntu provides built-in tools for every resource category. Knowing which tool to use for which resource — and what the output means — is a core operational skill.

CPU monitoring

# Quick CPU overview: load average and CPU breakdown
uptime
top

uptime output explained

 14:30:05 up 5 days, 2:10,  2 users,  load average: 2.10, 1.85, 1.72
#                                                    1min  5min  15min

# If load average > number of CPU cores → CPU bottleneck
# Check cores: nproc
# Continuous CPU monitoring
mpstat 2    # Per-CPU stats, 2-second interval (requires sysstat)
sar -u 2 10  # CPU utilization, 10 samples at 2-second intervals

# Find CPU-heavy processes
ps aux --sort=-%cpu | head -10

# Per-CPU core view in top: press 1 while in top
nproc    # Number of CPU cores
lscpu    # Full CPU information

Memory monitoring

# Memory overview
free -h

free -h output

               total        used        free      shared  buff/cache   available
Mem:            15Gi       5.2Gi       3.8Gi       220Mi       6.0Gi       9.5Gi
Swap:          2.0Gi          0B       2.0Gi

# 'available' (not 'free') = how much can processes use
# buff/cache is NOT wasted — Linux will reclaim it for processes when needed
# Continuous memory monitoring
vmstat 2    # Virtual memory stats including swap activity

# Memory by process
ps aux --sort=-%mem | head -10

# Detailed memory info
cat /proc/meminfo

# Monitor for memory pressure (oom events)
dmesg | grep -i "oom\|out of memory" | tail -5
sudo journalctl -k | grep -i oom | tail -5

Network monitoring

# Network interface statistics
ip -s link    # Packets/bytes sent/received per interface

# Real-time network bandwidth
sudo apt install -y iftop
sudo iftop -n    # -n = don't resolve hostnames (faster)

# Network connections
ss -tuln    # Listening ports (TCP+UDP)
ss -tunp    # All connections with process info
netstat -tuln  # Alternative (older tool)

# Per-process network usage
sudo apt install -y nethogs
sudo nethogs    # Show bandwidth per process

# Continuous network stats
sar -n DEV 2    # Network device stats every 2 seconds

All-in-one monitoring tools

# glances: comprehensive dashboard (CPU, memory, disk, network in one view)
sudo apt install -y glances
glances

# dstat: combines vmstat + iostat + ifstat in one view
sudo apt install -y dstat
dstat -cdnm 2    # CPU, disk, network, memory — 2-second interval
dstat -tam 2     # Time, all, memory

# nmon: interactive ncurses monitoring
sudo apt install -y nmon
nmon    # Press c=CPU, m=memory, d=disk, n=network, q=quit

dstat output (one line per 2 seconds)

----total-cpu-usage---- -dsk/total- -net/total- ------memory-usage-----
usr sys idl wai stl| read  writ| recv  send|  used  free  buff  cach
 12   3  83   2   0| 245k  890k|  45k   12k| 5200M 3800M  450M 6000M

Historical performance data

# sar collects historical performance data (if sysstat is enabled)
sudo apt install -y sysstat

# Enable sysstat collection
sudo systemctl enable --now sysstat

# View historical CPU data (today)
sar -u

# View historical data for a specific date
sar -f /var/log/sysstat/sa$(date +%d -d "yesterday")

# CPU history for last 24 hours
sar -u 1 > /dev/null; sar -u | tail -24

# Memory history
sar -r

# I/O history
sar -d

Conclusion

The core real-time monitoring toolkit: top or htop for CPU and memory, iostat -xhd 2 for disk I/O, iftop for network bandwidth, and vmstat 2 for a combined view including swap activity. Install glances or dstat for an all-in-one dashboard. Enable sysstat for historical data collection via sar — this is invaluable for post-incident analysis when you need to understand what was happening on the system an hour before a problem was noticed.

FAQ

Is System Resource Monitoring important for Ubuntu administrators?+

Yes. It supports practical Ubuntu administration because it connects directly to server reliability, security, troubleshooting, or daily operations.

Should I practice this on a live server?+

Use a lab VM first. After you understand the command output and rollback path, apply the workflow carefully on real systems.

What should I do after reading this article?+

Run the practice commands, write down what each one shows, and continue to the next article in the Ubuntu roadmap.

Need help with Ubuntu administration?

Work directly with Muhammad Irfan Aslam for Ubuntu Server, Linux, cloud, Docker, DevOps, CI/CD, or infrastructure troubleshooting support.

Hire Me for Support