Lab 11.1 - System Monitoring
Objectives
By the end of this lab, you will be able to:
- Monitor CPU, memory, disk with basic tools
- Use top, htop, iotop
- Create monitoring scripts
- Configure basic alerts
Prerequisites
- Ubuntu 24.04 installed
- Terminal open
- Tools: htop, iotop (optional)
Exercise 1: Installing Tools
# Install monitoring tools
sudo apt update
sudo apt install -y htop iotop sysstat
# Verify
which top htop iotop mpstat
Exercise 2: CPU Monitoring
# Real-time top
top
# Enhanced htop
htop
# CPU statistics
mpstat 1 5
# Load average
uptime
cat /proc/loadavg
Exercise 3: Memory Monitoring
# Overview
free -h
# Details
cat /proc/meminfo
# By process
ps aux --sort=-%mem | head -10
Exercise 4: Disk Monitoring
# Disk space
df -h
# Disk I/O
sudo iotop
# Statistics
iostat -x 1 5
Exercise 5: Monitoring Script
# Create a script
cat > monitor.sh << 'EOF'
#!/bin/bash
echo "=== $(date) ==="
echo "CPU: $(top -bn1 | grep 'Cpu(s)' | awk '{print $2}')"
echo "Memory: $(free -h | grep Mem | awk '{print $3"/"$2}')"
echo "Disk: $(df -h / | tail -1 | awk '{print $5}')"
echo "Load: $(uptime | awk -F'load average:' '{print $2}')"
EOF
chmod +x monitor.sh
./monitor.sh
Verification
- Monitor CPU, memory, disk
- Use top, htop, iotop
- Create monitoring scripts
Lab created on: December 2024 - Tested on Ubuntu 24.04