Centos clear swap usage

centos6swap

I got nagios monitoring and it is picking up high swap usage on a specific server. The user is using some application which triggers the high swap. Even after they quit the application, top still shows high swap used.

I've tried using swapoff -a and swapon -a. It doesn't reset the counter within top.

It seems like the only way to reset the counter is to reboot the server. Which is a pain.

enter image description here

Best Answer

For the swapoff command to work, there should be enough free physical memory so that the swapped files can be moved. As far as I can see, your amount of swap usage is very high and there is no way the system can free it.

See the swapoff man page: https://www.freebsd.org/cgi/man.cgi?query=swapoff&sektion=8

...Note that swapoff will fail and refuse to remove a swap device if there is insufficient VM (memory + remaining swap devices) to run the system...

There is certainly something wrong with your system which you should investigate. You can also try to run swapoff with the -v (for verbose) option to see if outputs more info.