命令:
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
来源:oschina
链接:https://my.oschina.net/u/727880/blog/3107456