Skip to content

Latest commit

 

History

History
64 lines (47 loc) · 2.33 KB

File metadata and controls

64 lines (47 loc) · 2.33 KB

Troubleshooting Drill: CPU, Memory, and Logs

1. CPU Troubleshooting

High CPU usage can slow down your system. Use these commands to monitor and investigate:

Command Description
top Real-time view of CPU usage by process.
htop Interactive, colorful version of top with easier navigation.
mpstat CPU usage per processor/core (sudo apt install sysstat on Debian/Ubuntu).
pidstat -u CPU usage per process over time.
uptime Shows system load averages for 1, 5, and 15 minutes.

Tips:

  • Identify processes consuming high CPU (%CPU in top/htop).
  • If a process is stuck, use kill -9 <PID> to terminate it.

2. Memory Troubleshooting

Memory issues can cause slowdowns or application crashes.

Command Description
free -h Shows total, used, and free memory in human-readable format.
vmstat 1 5 Provides memory, swap, and CPU statistics every second (5 times).
top / htop Check processes consuming high memory (%MEM).
smem Advanced memory reporting per process (install if not available).

Tips:

  • Check swap usage: if swap is high, consider optimizing memory or adding swap.
  • Monitor memory-hog processes and investigate leaks.

3. Log Troubleshooting

Logs help identify application or system errors.

Log File Description
/var/log/syslog General system messages (Debian/Ubuntu).
/var/log/messages General system messages (RedHat/CentOS).
/var/log/kern.log Kernel-related messages.
/var/log/auth.log Authentication logs, login attempts.
/var/log/dmesg Kernel ring buffer; hardware/boot messages.
/var/log/<service>.log Logs for individual services (like nginx, apache2, etc.).

Commands for Logs:

  • tail -f /var/log/syslog → Monitor log in real-time.
  • grep "error" /var/log/syslog → Search logs for specific keywords.
  • journalctl -u <service> → View logs for a specific systemd service.

4. Quick Troubleshooting Drill

  1. Check system load: uptime / top
  2. Identify CPU/memory hogs: htop
  3. Inspect logs for errors: tail -f /var/log/syslog
  4. Restart failing services: sudo systemctl restart <service>
  5. Verify service status: sudo systemctl status <service>