/엔지니어/OS / 시스템/리눅스 시스템 리소스 모니터링
OS / 시스템중급ubuntucentosdebianlinuxmonitoringcpu

리눅스 시스템 리소스 모니터링

CPU, 메모리, 디스크, 네트워크를 실시간으로 모니터링하고 병목을 찾는 실무 명령어와 도구를 정리했습니다.

CPU 모니터링

Bash
top -d 1
htop

uptime   # load average 확인 (코어 수보다 크면 과부하)
nproc
lscpu | grep "CPU(s):"

ps aux --sort=-%cpu | head -10

메모리 모니터링

Bash
free -h
watch -n 1 free -h

ps aux --sort=-%mem | head -10
cat /proc/meminfo | grep -E "MemTotal|MemFree|MemAvailable|Cached"
swapon --show

디스크 모니터링

Bash
df -h
df -h /var

du -sh /var/* | sort -rh | head -10
du -sh /*     | sort -rh | head -10

df -i   # inode 사용량

iostat -xz 1
iotop -ao

네트워크 모니터링

Bash
ss -tunlp
ss -s

iftop -i eth0
nload eth0

# 연결 수 확인 (DDoS 탐지)
ss -tn | awk 'NR>1 {print $5}' | cut -d: -f1 | sort | uniq -c | sort -rn | head

vmstat / sar

Bash
vmstat 1 10

sudo apt install sysstat
sar -u 1 5   # CPU
sar -r 1 5   # 메모리
sar -d 1 5   # 디스크

CPU 경보 스크립트

Bash
#!/bin/bash
THRESHOLD=90
CPU=$(top -bn1 | grep "Cpu(s)" | awk '{print $2}' | cut -d'%' -f1 | cut -d',' -f1)
CPU=${CPU%.*}

if [[ $CPU -gt $THRESHOLD ]]; then
  echo "[ALERT] CPU ${CPU}%" | mail -s "CPU 경고" [email protected]
fi
#linux#monitoring#cpu#memory#disk#iostat
편집 안내 · Editorial Note

이 가이드는 AI 도구를 활용해 초안을 구성하고 사람이 명령어·문맥을 검토해 발행했습니다. 운영체제와 도구 버전에 따라 결과가 달라질 수 있으므로 적용 전 공식 문서를 함께 확인하세요. 오류를 발견하시면 이메일로 제보해 주세요.

관련 공식 문서GNU/Linux man 페이지

질문 & 답변 (Q&A)

이 가이드에 대해 궁금한 점을 질문해보세요. 확인 후 답변드립니다.