1.测试CPU,最高CPU,最低CPU,平均CPU,单个进程如wlan的CPU占比,脚本后面接的第一个参数是要打印cpu的次数,第二个是sleep多久,第三个参数是记录当前数据的路径path
#!/bin/sh if [ $# != 3 ];then echo "wrong parameter!" exit 1 fi checktime=$1 check=1 allcpu=0 logpath=$3"/cpu.txt" echo "" > $logpath echo "======================CPU==========================" >> $logpath echo "NO. date avg_cpu Sys_cpu apd_Cpu" >> ./log/cpu.txt while [ $check -le $checktime ] do docpu=`cpu -c 1` cucpu=`echo $docpu | cut -b 11-14 | cut -d \% -f 1` allcpu=`expr $allcpu + $cucpu` avcpu=`expr $allcpu / $check` hc=`ps -aux | grep hostapd | grep -v grep | awk '{print $3}'` echo "$check `date` $avcpu% $cucpu% $hc%" >> $logpath sleep $2 check=`expr $check + 1` done echo "finish cpu test"