这个答案提供了一个很好的脚本,显示每个进程使用的交换量:How to find out which processes are swapping in linux?
然而:
petr@eliska:~$ free
total used free shared buffers cached
Mem: 3114288 2930040 184248 0 76 1809800
-/+ buffers/cache: 1120164 1994124
Swap: 6287356 977712 5309644
注意:使用了977MB的交换区,当我运行这个问题上面链接的脚本时,我看到
PID=1 swapped 76 KB (init)
PID=369 swapped 404 KB (udevd)
PID=463 swapped 356 KB (udevd)
PID=464 swapped 348 KB (udevd)
PID=1804 swapped 1556 KB (dhclient)
PID=1859 swapped 168 KB (rpcbind)
PID=1890 swapped 408 KB (rpc.statd)
PID=1904 swapped 184 KB (rpc.idmapd)
PID=2240 swapped 348 KB (rsyslogd)
PID=2304 swapped 108 KB (acpid)
PID=2452 swapped 112 KB (atd)
PID=2529 swapped 136 KB (dbus-daemon)
PID=2544 swapped 312 KB (ntpd)
PID=2779 swapped 364 KB (memcached)
PID=2786 swapped 332 KB (sshd)
PID=2859 swapped 128 KB (cron)
PID=2878 swapped 300 KB (exim4)
PID=2904 swapped 132 KB (getty)
PID=2905 swapped 128 KB (getty)
PID=2906 swapped 124 KB (getty)
PID=2907 swapped 128 KB (getty)
PID=2908 swapped 128 KB (getty)
PID=2909 swapped 128 KB (getty)
PID=2918 swapped 744 KB (console-kit-dae)
PID=2985 swapped 156 KB (polkitd)
PID=3243 swapped 3228 KB (node)
PID=3246 swapped 1688 KB (node)
PID=3247 swapped 2580 KB (node)
PID=3249 swapped 2160 KB (node)
PID=3250 swapped 2336 KB (node)
PID=3251 swapped 1900 KB (node)
PID=3686 swapped 16 KB (oracle)
PID=16915 swapped 16 KB (oracle)
PID=29843 swapped 204 KB (java)
PID=29868 swapped 2512 KB (emagent)
PID=29925 swapped 1060 KB (oracle)
Overall swap used: 25008 KB
我该如何分析交换区域,以便可以看到这些(977-25)MB用于什么?有没有什么方法可以读取交换是如何使用的,以及交换的哪些部分用于什么?
最佳答案
尝试跟随
cat /proc/PID/status | grep VmSwap
此脚本将显示所有进程的交换使用情况。(您可以使用grep查找任何完全匹配的
#!/bin/bash
for file in /proc/*/status ;
do
awk '/VmSwap|Name/{printf $2 " " $3}END{ print ""}' $file;
done
关于linux - 如何在Linux上检索交换空间的详细用法,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/21329977/