리눅스 CPU 사용률 확인

1 방법1: mpstat[ | ]

명령어
mpstat | tail -1 | awk '{print 100-$NF}'
실행예시
# mpstat
Linux 3.10.0-862.14.4.el7.x86_64 (centos7)      11/14/2019      _x86_64_        (1 CPU)

07:36:08 AM  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle
07:36:08 AM  all    0.44    0.00    0.39    0.21    0.00    0.03    0.00    0.00    0.00   98.93
# mpstat | tail -1 | awk '{print 100-$NF}'
1.07
→ CPU 사용률은 1.07%이다.[1]

2 방법2: top ★[ | ]

명령어
top -b -n1 | grep -Po '[0-9.]+ id' | awk '{print 100-$1}'
실행예시
root@centos7:~# top -b -n1 | grep -Po '[0-9.]+ id'
93.8 id
root@centos7:~# top -b -n1 | grep -Po '[0-9.]+ id' | awk '{print 100-$1}'
6.2
→ CPU 사용률은 6.2 %이다.[2]

3 같이 보기[ | ]

4 참고[ | ]

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