"리눅스 CPU 사용률 확인"의 두 판 사이의 차이

7번째 줄: 7번째 줄:
;실행예시
;실행예시
<source lang='dos'>
<source lang='dos'>
nsmap01:~ # mpstat | tail -1 | awk '{print 100-$11}'
[root@jmnote ~]# mpstat | tail -1 | awk '{print 100-$11}'
7.83
7.83
</source>
</source>
20번째 줄: 20번째 줄:
;실행 예시
;실행 예시
<source lang='dos'>
<source lang='dos'>
nsmap01:~ # top -n 1 | grep -i cpu\(s\)| awk '{print $5}' | tr -d "%id," | awk '{printf("%f\n", 100-$1)}'
[root@jmnote ~]# top -n 1 | grep -i cpu\(s\)| awk '{print $5}' | tr -d "%id," | awk '{printf("%f\n", 100-$1)}'
7.800000
7.800000
</source>
</source>

2012년 12월 18일 (화) 09:50 판

1 방법1: mpstat

명령어
mpstat | tail -1 | awk '{print 100-$11}'
실행예시
[root@jmnote ~]# 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)}'
실행 예시
[root@jmnote ~]# 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 같이 보기

4 주석

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