查看进程的swap 使用量并进行排序取前20
bash
## 单位GB
for file in /proc/*/status ; do awk '/VmSwap|Name|^Pid/{printf $2 " " $3}END{ print ""}' $file; done |awk '{printf ("%s\t%s\t%.2f GB\t\n",$1,$2,$3/1024/1024)}' |sort -k 3 -n -r | head -n 20
## 单位MB
for file in /proc/*/status ; do awk '/VmSwap|Name|^Pid/{printf $2 " " $3}END{ print ""}' $file; done |awk '{printf ("%s\t%s\t%.2f MB\t\n",$1,$2,$3/1024)}' |sort -k 3 -n -r | head -n 20
查看进程的申请的内存量并进行排序取前20
bash
## 单位GB
for file in /proc/*/status ; do awk '/VmSize|Name|^Pid/{printf $2 " " $3}END{ print ""}' $file; done |awk '{printf ("%s\t%s\t%.2f GB\t\n",$1,$2,$3/1024/1024)}' |sort -k 3 -n -r | head -n 20
## 单位MB
for file in /proc/*/status ; do awk '/VmSize|Name|^Pid/{printf $2 " " $3}END{ print ""}' $file; done |awk '{printf ("%s\t%s\t%.2f MB\t\n",$1,$2,$3/1024)}' |sort -k 3 -n -r | head -n 20
查看进程的已申请的的物理内存并进行排序取前20
bash
## 单位GB
for file in /proc/*/status ; do awk '/VmSize|Name|^Pid/{printf $2 " " $3}END{ print ""}' $file; done |awk '{printf ("%s\t%s\t%.2f GB\t\n",$1,$2,$3/1024/1024)}' |sort -k 3 -n -r | head -n 20
## 单位MB
for file in /proc/*/status ; do awk '/VmSize|Name|^Pid/{printf $2 " " $3}END{ print ""}' $file; done |awk '{printf ("%s\t%s\t%.2f MB\t\n",$1,$2,$3/1024)}' |sort -k 3 -n -r | head -n 20