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

32번째 줄: 32번째 줄:
* [[top]]
* [[top]]
* [[sar]]
* [[sar]]
* [[부하 평균]] (load average)
* [[부하 평균]](load average)
[[분류:리눅스]]
[[분류:리눅스]]
[[분류:CPU]]
[[분류:CPU]]

2012년 12월 1일 (토) 14:40 판

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 }}