Get out of my swa(m)p!

One of my servers recently had been using a lot of swap space, more than usual.

This got me curious as to what could be using that swap space.

Important note: I had not noticed any slow down on any of the applications hosted on this server, and the swap is being used as expected, I am just interested as to what is using it/what processes are unused and going into swap.

I stumbled upon this (thank you), which has some very interesting commands, what peaked my interest however, was the following:

for file in /proc/*/status ; do awk ‘/VmSwap|Name/{printf $2 ” ” $3}END{ print “”}’ $file; done | sort -k 2 -n -r | less

This command works through each process and reports back how much swap space is being used by it, sorts them and pipes into less for ease of reading.

In my case, it was a docker application that is very sparsely used and is just sitting comfortably in swap until I need it.

You May Also Like

Leave a Reply

Your email address will not be published. Required fields are marked *