What’s cpulimit
http://cpulimit.sourceforge.net/
You can force a running process to limit CPU usage.
[ How to install cpulimit ]
CentOS 5.5
There is no cpulimit package in yum repository.
download source code n’ compile.
compile
file name cpulimit is binary file you compiled.
Ubuntu 10.10
you can install it via apt-get
[ Examples of usage ]
To limit CPU usage , at first you need to find a process ID or command name w/ ps aux , top etc.
http://cpulimit.sourceforge.net/
You can force a running process to limit CPU usage.
[ How to install cpulimit ]
CentOS 5.5
There is no cpulimit package in yum repository.
download source code n’ compile.
# wget http://sourceforge.net/projects/cpulimit/files/cpulimit/cpulimit/cpulimit-1.1.tar.gz [root@centos5-1 ~]# tar xzvf cpulimit-1.1.tar.gz [root@centos5-1 ~]# cd cpulimit-1.1 [root@centos5-1 cpulimit-1.1]# ls Makefile cpulimit.c |
compile
[root@centos5-1 cpulimit-1.1]# make gcc -o cpulimit cpulimit.c -lrt -Wall -O2 |
file name cpulimit is binary file you compiled.
[root@centos5-1 cpulimit-1.1]# cp cpulimit /usr/local/sbin/ |
Ubuntu 10.10
you can install it via apt-get
root@hat1:~# apt-get install cpulimit |
[ Examples of usage ]
To limit CPU usage , at first you need to find a process ID or command name w/ ps aux , top etc.
[root@centos5-1 cpulimit-1.1]# cpulimit --verbose Error: You must specify a target process 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 |
root@hat1:~# ps -C unbound PID TTY TIME CMD 1571 ? 00:00:01 unbound |
root@hat1:~# cpulimit --pid 1571 --limit 10 Process 1571 detected |
or
root@hat1:~# cpulimit --exe unbound --limit 10 Process 1571 detected |
display details
root@hat1:~# cpulimit --pid 1571 --limit 10 --verbose Process 1571 detected %CPU work quantum sleep quantum active rate 0.00% 100000 us 0 us 99.80% 0.00% 100000 us 0 us 99.80% 0.00% 100000 us 0 us 99.81% 0.00% 100000 us 0 us 99.80% |
limit CPU usage of chrome browser by only 1% ,,, oh very slow..
root@hat1:~# cpulimit --exe chromium-browser --limit 1 --verbose Process 2829 detected %CPU work quantum sleep quantum active rate 1.11% 84803 us 15196 us 93.87% 5.53% 4244 us 95755 us 23.49% 2.21% 1082 us 98917 us 2.40% 2.21% 6587 us 93412 us 14.58% 3.32% 1384 us 98615 us 4.60% 2.21% 444 us 99555 us 0.98% 2.21% 233 us 99766 us 0.52% 7.75% 1477 us 98522 us 11.45% 2.21% 500 us 99499 us 1.11% 1.11% 415 us 99584 us 0.46% |
cpulimit seems to limit CPU usage by SIGSTOP n’ SIGCONT
interesting tool :)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.