Linux ETC

CPU 사용률 제한

2015.09.18 12:40

호스트웨이 조회 수:3484

WEB 및 DB등 운영중인 서버에서 백업,배치등의 이유로 CPU부하가 발생 하는 경우가 있습니다.

이럴때 각 프로세에 CPU limit설정 하여 자원 확보하는 프로그램이 있습니다.


#download

- http://sourceforge.net/projects/cpulimit/files/cpulimit/cpulimit/cpulimit-1.1.tar.gz/download?use_mirror=jaist&r=&use_mirror=cdnetworks-kr-1 


#install

[root@apm ~]# ls -la |grep cpulimit-1.1.tar.gz

-rw-r--r--   1 root root    5130 Sep 18 11:41 cpulimit-1.1.tar.gz

[root@apm ~]# tar zxvf cpulimit-1.1.tar.gz

cpulimit-1.1/

cpulimit-1.1/Makefile

cpulimit-1.1/cpulimit.c

[root@apm ~]# cd cpulimit-1.1

[root@apm cpulimit-1.1]# make

gcc -o cpulimit cpulimit.c -lrt -Wall -O2

[root@apm cpulimit-1.1]# ls -la

total 48

drwxr-xr-x  2 1002 root   4096 Sep 18 11:57 .

dr-xr-x---. 5 root root   4096 Sep 18 11:57 ..

-rwxr-xr-x  1 root root  17070 Sep 18 11:57 cpulimit

-rw-r--r--  1 1002 users 14146 Jun 27  2005 cpulimit.c

-rw-r--r--  1 1002 users   107 Jun 24  2005 Makefile

[root@apm cpulimit-1.1]#


#execute
[root@apm cpulimit-1.1]# ps -ef |grep gzip
root     27155 26446 96 12:00 pts/1    00:00:30 gzip -9
root     27162 26446  0 12:01 pts/1    00:00:00 grep gzip
[root@apm cpulimit-1.1]#

./cpulimit -p 27155 -l 30 &


[root@apm cpulimit-1.1]# ps -ef |grep gzip
root     27155 26446 30 12:00 pts/1    00:37:02 gzip -9
root     28643 26446  0 12:39 pts/1    00:00:00 grep gzip

#option
[root@apm cpulimit-1.1]# ./cpulimit --h
Usage: cpulimit TARGET [OPTIONS...]
   TARGET must be exactly one of these:
      -p, --pid=N        pid of the process
      -e, --exe=FILE     name of the executable program file
      -P, --path=PATH    absolute path name of the executable program file
   OPTIONS
      -l, --limit=N      percentage of cpu allowed from 0 to 100 (mandatory)
      -v, --verbose      show control statistics
      -z, --lazy         exit if there is no suitable target process, or if it dies
      -h, --help         display this help and exit


감사합니다.



번호 제목 글쓴이 날짜 조회 수
366 TCp syn Flooding 공격시 대처방법 TIP 호스트웨이 2012.10.26 2238
365 vim fileformat 변경하기: -bash: ./LINUX_03.sh: /bin/sh^M: bad interpreter: No such file or directory 호스트웨이 2012.11.29 2292
364 리눅스 시스템상에서 하드웨어사양 확인 호스트웨이 2012.10.24 2369
363 500 FTP server shut down 문제 해결 호스트웨이 2015.09.09 2400
362 rsync / 파티션 전체 동기화 방법 호스트웨이 2012.12.14 2428
361 ispell 명령어를 통한 철자 검사 및 수정하기 file 호스트웨이 2012.10.12 2523
360 리눅스 look 명령어 file 호스트웨이 2012.11.02 2598
359 hostname 변경하기 호스트웨이 2015.09.17 2621
358 리눅스 hdd 속도 알아보기 호스트웨이 2015.09.17 2623
357 쉘 프롬프트 설정하기 file 호스트웨이 2012.11.08 2671
356 읽기 전용 파티션 읽고 쓸수 있게 재마운트하는 방법 호스트웨이 2015.09.13 2718
355 랜카드 본딩(bond0) 설정 호스트웨이 2012.11.16 2719
354 쉘 프롬프트에서 바로 이전 디렉토리로 이동하기 호스트웨이 2012.12.20 2751
353 UTF-8 환경에서 리눅스 한글 꺠짐 현상 해결법 호스트웨이 2015.09.08 2771
352 df 쉽게 보기 호스트웨이 2012.12.20 2835
351 /proc/sys/net/ipv4 활용 서버보안 -1- 호스트웨이 2015.09.17 2838
350 SNMPD LOG 안남게 하기 호스트웨이 2015.09.10 2891
349 리눅스 tree 명령어 file 호스트웨이 2012.09.21 2930
348 yum을 이용한 X-Window 설치 호스트웨이 2012.09.27 3004
347 INIT: no more processes left in this runlevel 메세지 발생시 호스트웨이 2012.11.15 3018