Monitoring your VPS performance is essential for maintaining reliability, identifying bottlenecks, and planning capacity. Without proper monitoring, you are flying blind - small issues can compound into downtime, and you will not know if your application is outgrowing its resources until users start complaining. This guide covers the tools and techniques every SakuraHost VPS administrator should implement.

Quick Overview: This guide covers command-line tools (htop, vmstat, iostat), log analysis, disk and network monitoring, and automated alerting. For understanding what your VPS resources mean, see Understanding VPS Resource Allocation: CPU, RAM, and Storage.

1. Real-Time System Monitoring

htop - Interactive Process Viewer

htop is the go-to tool for real-time process monitoring with an intuitive color-coded interface.

sudo apt install htop -y htop

Key information displayed by htop includes CPU usage per core, memory and swap utilization, running processes sorted by resource consumption, load averages, and uptime. Use F6 to sort by different columns, F9 to kill processes, and F5 for tree view showing parent-child relationships.

Understanding Load Averages

The three load average numbers represent system load over 1, 5, and 15 minutes. For a VPS with 2 CPU cores:

  • Load < 2.0 - System is handling the workload comfortably
  • Load 2.0 - 4.0 - System is busy but responsive
  • Load > 4.0 - System is overloaded, investigate immediately

A simple check: uptime shows load averages without entering an interactive tool.

2. CPU and Memory Analysis

vmstat - Virtual Memory Statistics

# Report every 2 seconds, 10 iterations vmstat 2 10

Key columns to watch in vmstat output:

  • r (run queue) - Processes waiting for CPU. Consistently above your CPU count indicates saturation
  • si/so (swap in/out) - Any non-zero values mean RAM is insufficient and the system is using slow disk-based swap
  • us/sy/id - User, system, and idle CPU percentages. High system (sy) may indicate kernel-level issues
  • wa (wait) - CPU time spent waiting for I/O. High values suggest disk bottleneck

free - Memory Usage Summary

# Human-readable format, updated every 3 seconds free -h -s 3
Understanding Linux Memory: Do not panic if "used" memory appears high. Linux aggressively caches disk data in RAM for performance. The critical number is "available" memory - this is what is actually free for new applications. If "available" drops below 10% of total RAM consistently, consider upgrading.

3. Disk I/O Monitoring

iostat - Disk Performance

sudo apt install sysstat -y iostat -xz 2

Critical iostat metrics:

  • %util - Disk utilization. Above 80% sustained indicates a disk bottleneck
  • await - Average time (ms) for I/O requests. Below 10ms is excellent, above 50ms is concerning
  • r/s and w/s - Read and write operations per second (IOPS)

Disk Space Monitoring

# Overall disk usage df -h # Find largest directories du -sh /* 2>/dev/null | sort -rh | head -20 # Find large files find / -type f -size +100M -exec ls -lh {} ; 2>/dev/null

4. Network Monitoring

iftop - Network Bandwidth Monitor

sudo apt install iftop -y sudo iftop -i eth0

iftop shows real-time bandwidth usage per connection, making it easy to identify which services or IP addresses are consuming the most bandwidth.

ss - Socket Statistics

# Show all listening ports and their processes ss -tlnp # Count established connections per port ss -s # Show connections to specific port (e.g., web server) ss -tn state established '( dport = :80 or dport = :443 )'

5. Log Monitoring and Analysis

Logs are your primary debugging tool. Key log files to monitor:

# System messages sudo tail -f /var/log/syslog # Authentication attempts (watch for brute force) sudo tail -f /var/log/auth.log # Nginx access and errors sudo tail -f /var/log/nginx/access.log sudo tail -f /var/log/nginx/error.log # Kernel messages dmesg -T --level=err,warn

journalctl for Systemd Logs

# Recent logs from all services journalctl -xe --since "1 hour ago" # Logs from a specific service journalctl -u nginx --since today # Follow logs in real-time journalctl -f

6. Automated Monitoring Scripts

Create a simple monitoring script that alerts you when resources exceed thresholds:

#!/bin/bash # /usr/local/bin/monitor-vps.sh CPU_THRESHOLD=80 MEM_THRESHOLD=85 DISK_THRESHOLD=90 EMAIL="admin@example.com" CPU_USAGE=$(top -bn1 | grep "Cpu(s)" | awk '{print $2}' | cut -d. -f1) MEM_USAGE=$(free | grep Mem | awk '{printf("%.0f", $3/$2 * 100)}') DISK_USAGE=$(df / | tail -1 | awk '{print $5}' | tr -d '%') if [ "$CPU_USAGE" -gt "$CPU_THRESHOLD" ] || [ "$MEM_USAGE" -gt "$MEM_THRESHOLD" ] || [ "$DISK_USAGE" -gt "$DISK_THRESHOLD" ]; then echo "ALERT: CPU=${CPU_USAGE}% MEM=${MEM_USAGE}% DISK=${DISK_USAGE}%" | mail -s "VPS Resource Alert" $EMAIL fi

Schedule it with cron to run every 5 minutes:

crontab -e # Add: */5 * * * * /usr/local/bin/monitor-vps.sh

7. Performance Benchmarking

# CPU benchmark sysbench cpu run # Memory benchmark sysbench memory run # Disk I/O benchmark sysbench fileio --file-test-mode=rndrw prepare sysbench fileio --file-test-mode=rndrw run sysbench fileio --file-test-mode=rndrw cleanup
Need to Scale? If monitoring consistently shows resource constraints, it may be time to upgrade your VPS. See our guide How to Scale Your VPS: Upgrading Resources and Load Balancing. Upgrade your plan at billing.sakurahost.co.tz. For more monitoring strategies, see the DigitalOcean Server Monitoring Guide and Ubuntu Server Documentation.
Was this answer helpful? 0 Users Found This Useful (0 Votes)