0

is there an (easy(?)) way to get the the amount of data moved to/from swap over a certain time ? Maybe, either integrated over all processes and time or integrated over specific processes and time?

Story: I have a machine which tends to swap. However, I do not know, if swap is 'actively' used. I.e., if it is constantly swapping or let's say just the shared libraries not really used are swapped away after some time and 'active' memory usage happens in mem in the end.

Thus, I am looking for a way to comfort myself, that the swap usage may be not serious...

Cheers and thanks for ideas, Thomas

4

2 回答 2

0

这是我使用 vmstat 在调用之间换入/换出的总页数的临时解决方案

#!/bin/sh
OLDSWAPPEDIN=$SWAPPEDIN
OLDSWAPPEDOUT=$SWAPPEDOUT
PAGEINOUT=$(vmstat -s | grep swapped 2>&1)
SWAPPEDIN=`echo $PAGEINOUT | awk '{print $1}'`
SWAPPEDOUT=`echo $PAGEINOUT | awk '{print $5}'`
SWAPPEDINDIFF=`expr $SWAPPEDIN - $OLDSWAPPEDIN`
SWAPPEDOUTDIFF=`expr $SWAPPEDOUT - $OLDSWAPPEDOUT`

我试图避免存储变量的临时文件(因此需要采购它或在登录时创建变量)

于 2013-08-08T09:22:00.210 回答
0

这可以通过 SystemTap 相对容易地完成(如果您知道内核 MM 子系统)。您需要知道执行 swapin/swapout、创建相应探针和从探针递增的两个计数器的函数的名称。最后,您需要一个每 N 秒触发一次的计时器,转储当前计数器并重置它们。

于 2013-08-07T13:18:15.680 回答