Monday, March 18, 2013

Linux and swap

run top, then O (uppercase o), p and Enter

this will show you all processes sorted by SWAP used



  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  SWAP COMMAND
16103 soa3      23   0 3109m 1.3g  34m S  0.0  8.3  12:02.82 1.7g java
 4091 soa3      19   0 3115m 1.5g  34m S  0.0  9.7  11:35.79 1.5g java
12193 soa       20   0 1122m 293m 8764 S  0.0  1.8   0:23.88 828m java
25674 soa3      21   0 2152m 1.3g  50m S  0.0  8.5   7:38.07 786m java
17344 soa2      21   0 2355m 1.7g  51m S  0.0 10.6  16:16.17 652m java
 3435 soa2      21   0 3326m 2.6g  35m S  0.0 16.7  43:47.83 639m java



top computes SWAP as VIRT - RES.

( see here for more details)

To examine how swap is configured on your machine (can be file or partition):

/sbin/swapon -s

Filename                                Type            Size    Used    Priority
/dev/mapper/rootvg-swaplv               partition       8388600 188     -1


and cat /proc/swaps to view the same info.

do "cat /etc/fstab", you should see a line to mount the partition on boot:

/dev/rootvg/swaplv swap swap defaults 0 0

check your swappiness this way:
cat /proc/sys/vm/swappiness
60

Use also vmstat 5 to trace si and so (swap in and swapout)



No comments: