检查服务器内存资源占用进程信息
通过命令快速获取服务器内存资源占用信息,方便分析项目资源占用情况。
{
echo "";
echo "";
echo "";
echo "总内存和CPU使用百分比:";
ps -eo %mem,%cpu --sort=-%mem | awk 'NR>1 {mem+=$1; cpu+=$2} END {print "总%mem: " mem "%\n总%cpu: " cpu "%"}';
echo "";
echo "";
echo "";
echo "内存占用前10的进程:";
ps -eo %mem,%cpu,pid,cmd --sort=-%mem | head -n 11;
echo "";
echo "";
echo "";
echo "CPU占用前10的进程:";
ps -eo %mem,%cpu,pid,cmd --sort=-%cpu | head -n 11;
}
https://discuss.plugins-world.cn/post/B0Q4k8Jj