【CPU】记录当前嵌入式设备CPU 比较最高CPU 并打印出来
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"
声明 欢迎转载,但请保留文章原始出处:) 博客园:https://www.cnblogs.com/chenxiaomeng/
如出现转载未声明 将追究法律责任~谢谢合作