리눅스 CPU 사용률 확인

Jmnote (토론 | 기여)님의 2012년 10월 24일 (수) 09:57 판 (→‎같이 보기)

1 방법

1.1 명령어

top -n 1 | grep -i cpu\(s\)| awk '{print $5}' | tr -d "%id," | awk '{printf("%f\n", 100-$1)}'

1.2 실행 예시

[root@localhost ~]# top -n 1 | grep -i cpu\(s\)| awk '{print $5}' | tr -d "%id," | awk '{printf("%f\n", 100-$1)}'
1.300000

→ CPU 사용률은 1.3 %이다.

2 변수에 담기

2.1 명령어

PBUSY=`top -n 1 | grep -i cpu\(s\)| awk '{print $5}' | tr -d "%id," | awk '{printf("%f\n", 100-$1)}'`

2.2 실행 예시

[root@localhost ~]# PBUSY=`top -n 1 | grep -i cpu\(s\)| awk '{print $5}' | tr -d "%id," | awk '{printf("%f\n", 100-$1)}'`
[root@localhost ~]# echo $PBUSY
1.300000


3 같이 보기

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}