本帖最后由 赵阳光 于 2013-4-11 16:27 编辑
cpulimit是一个开源的cpu使用限制工具,可以针对某个进程名、pid等来限制cpu使用率 以下是拿发烧友的高端机器hg32064M内存机器测试!理论rt-n及mipsel r2系列的路由都是可以的! 安装方法非常简单(需要路由安装optware环境) 将附件cpulimit_1.8-1_mipsel.ipk上传到/tmp目录下,执行: ipkg install cpulimit_1.8-1_mipsel.ipk 看到如下,就是安装成功了:
使用方法如下: root@unknown:/tmp# cpulimit Error: You must specify a target process CPUlimit version 1.7 Usage: cpulimit TARGET [OPTIONS...] TARGET must be exactly one of these: -p, --pid=N pid of theprocess -e, --exe=FILE name of theexecutable program file The -e option onlyworks when cpulimit is run withadmin rights. -P, --path=PATH absolute pathname of the executable programfile OPTIONS -b --background run in background -c --cpu=N override the detection of CPUs on themachine. -l, --limit=N percentage ofcpu allowed from 1 up. Usually 1 - 100, butcan be higher on multi-core CPUs (mandatory) -v, --verbose show controlstatistics -z, --lazy exit if thereis no suitable target process, or if it dies -h, --help display thishelp and exit root@unknown:/tmp# 可以看到帮助信息 使用参数:例 root@unknown:/tmp/home/root# cpulimit -earia2c -l 40 -b & -e是进程名字或者进程路径,-l是cpu的最高占用率,-b参数是后台运行。 可以对aria2c这个程序限制cpu使用率为40% 添加了一个能全速的ubuntu镜像iso下载链接,下载速度达到了1M/s。
未使用cpulimit限制的情况下,cpu使用达到最高达到54%了,可想而知,多个bt种子的时候,cpu占用甚至更高,这样路由器长时间工作就会出现发热量大,其他程序运行延迟甚至掉线的情况。
使用cpulimit命令限制aria2c使用率40%
接下来可以看到cpulimit起作用了,将aria2c进程的cpu占用率控制在40%以下了。 PS:aria2 的cpu使用率建议限制在50%左右。限制低了aria2的下载速度自然就降低了! 下载cpulimit:
|