리눅스 CPU 사용률 확인

Jmnote (토론 | 기여)님의 2012년 12월 18일 (화) 09:48 판

1 방법1: mpstat

명령어
mpstat | tail -1 | awk '{print 100-$11}'
실행예시
nsmap01:~ # mpstat | tail -1 | awk '{print 100-$11}'
7.83
→ CPU 사용률은 7.83 %이다.[1]

2 방법2: top

명령어
top -n 1 | grep -i cpu\(s\)| awk '{print $5}' | tr -d "%id," | awk '{printf("%f\n", 100-$1)}'
실행 예시
nsmap01:~ # top -n 1 | grep -i cpu\(s\)| awk '{print $5}' | tr -d "%id," | awk '{printf("%f\n", 100-$1)}'
7.800000
→ CPU 사용률은 7.8 %이다.[2]

3 같이 보기

  1. mpstat은 소수점 둘째 자리까지 확인 가능.
  2. top은 소수점 첫째 자리까지 확인 가능.
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}