Identifying the culprit
# Basic: shows CPU-sorted process list, updated every 3 seconds
top
# Better interactive view
apt install htop && htop
# Snapshot of the top 15 CPU consumers
ps aux --sort=-%cpu | head -15
Common causes and fixes
Web server (Nginx / Apache) overloaded
Check request rate:
tail -f /var/log/nginx/access.log | awk '{print $1}' | sort | uniq -c | sort -rn | head
Mitigation: Add rate limiting in Nginx, enable caching, or upgrade to a plan with more vCPUs.
Database queries running hot
# MySQL / MariaDB — show running queries
mysql -e "SHOW PROCESSLIST;"
# PostgreSQL
sudo -u postgres psql -c "SELECT pid, query, state FROM pg_stat_activity WHERE state != 'idle';"
Crypto-mining malware
Signs: CPU consistently near 100%, unknown process names, network activity to mining pool IPs.
ps aux | grep -i "xmrig\|minerd\|cpuminer"
netstat -antp | grep ESTABLISHED | grep -v sshd
If you find malware, take a snapshot immediately, then terminate the server and redeploy from a clean image. Change all passwords and rotate SSH keys. Open a security ticket — we can assist with forensic analysis.
Runaway cron job or script
# Identify by time — if a process has been running for hours
ps -eo pid,etime,cmd | sort -k2 -r | head
# Check cron logs
grep CRON /var/log/syslog | tail -20