使用top分析tomcat容器占用的内存排行

戏子无情 提交于 2020-03-01 16:26:48

命令:
top -b -n1 | awk 'NR<=7{print;next}{n=$6;if(n~/m/)n*=1024;if(n~/g/)n*=1024*1024;a[sprintf("%12d",n)]=$0"\n"a[n]}END{c=asorti(a,b);for(n=c;n>0;n--)printf("%s", a[b[n]])}'|grep -A 10 'COMMAND' |grep 'java'|awk '{print $1 " " $6}'|while read line; do pid=$(echo $line|awk '{print $1}'); mem=$(echo $line|awk '{print $2}'); name=$(cd /var/lib/docker/containers;grep -R Pid ./*|grep Pid|grep ${pid}|grep -o "\"/[a-zA-Z]*-0"|sed 's#"/##'); echo -e "${pid}\t${mem}\t${name}"; done

CRT button:
top -b -n1 | awk 'NR<=7{print;next}{n=$6;if(n~/m/)n*=1024;if(n~/g/)n*=1024*1024;a[sprintf("%12d",n)]=$0"\\n"a[n]}END{c=asorti(a,b);for(n=c;n>0;n--)printf("%s", a[b[n]])}'|grep -A 10 'COMMAND' |grep 'java'|awk '{print $1 " " $6}'|while read line; do pid=$(echo $line|awk '{print $1}'); mem=$(echo $line|awk '{print $2}'); name=$(cd /var/lib/docker/containers;grep -R Pid ./*|grep Pid|grep ${pid}|grep -o "\\"/[a-zA-Z]*-0"|sed 's#"/##'); echo -e "${pid}\\t${mem}\\t${name}"; done \n

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!