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

 
1번째 줄: 1번째 줄:
#넘겨주기 [[리눅스 프로세스 CPU 사용률]]
==방법==
===명령어===
<source lang='bash'>
top -n 1 | grep -i cpu\(s\)| awk '{print $5}' | tr -d "%id," | awk '{printf("%f\n", 100-$1)}'
</source>
 
===실행 예시===
<source lang='dos'>
[root@localhost ~]# top -n 1 | grep -i cpu\(s\)| awk '{print $5}' | tr -d "%id," | awk '{printf("%f\n", 100-$1)}'
1.300000
</source>
→ CPU 사용률은 1.3 %이다.
 
==변수에 담기==
===명령어===
<source lang='bash'>
PBUSY=`top -n 1 | grep -i cpu\(s\)| awk '{print $5}' | tr -d "%id," | awk '{printf("%f\n", 100-$1)}'`
</source>
 
===실행 예시===
<source lang='dos'>
[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
</source>
 
 
==같이 보기==
* [[리눅스 프로세스 CPU 사용률]]
* [[리눅스 CPU 유휴율]]
 
[[분류:리눅스]]
[[분류:CPU]]

2012년 3월 2일 (금) 03:44 판

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