After reading another thread here and after answering a similar question a few times on IRC I thought I would bring this one back in to the lime light.
http://www.lowendbox.com/blog/how-to-tell-your-openvz-vps-is-swapping/
Think of this as one of those, how many IOPS do you get, dd results type threads:
tl;dr for people who dont want to read all the info in the link
1) go to: http://hostingfu.com/article/vzfree-checking-memory-usage-inside-openvz-ve
2) wget http://hostingfu.com/files/vzfree/vzfree-0.1.tgz
3) install make gcc, e.g. yum install gcc make or apt-get install make gcc
4) make
5) make install
then run vzfree and you get an output like:
racksrv.com 512MB VPS, zero unplanned down time in 2 years.
Racksrv Nodes are enterprise grade and they have never been featured on LEB.
Total Used Free Kernel: 2048.00M 4.49M 2043.51M Allocate: 512.00M 126.91M 385.09M (512M Guaranteed) Commit: 512.00M 96.02M 415.98M (72.1% of Allocated) Swap: 0.00M (0.0% of Committed)
quickweb 512MB VPS, 1 unplanned outage in 18 months due to disk failure whcih is completely acceptable.
Quickweb seems to have left LEB behind quite some time ago.
Total Used Free Kernel: 2048.00M 5.44M 2042.56M Allocate: 768.00M 192.81M 575.19M (512M Guaranteed) Commit: 512.00M 71.65M 440.35M (34.3% of Allocated) Swap: 0.00M (0.0% of Committed)
The other more simple approach is a little script that long time member @rm wrote
#!/bin/bash cat /proc/user_beancounters | grep -E '(uid|physpages|oomguarpages)' PHYS=`cat /proc/user_beancounters | grep " physpages " | awk '{print $2}'` OOMGUAR=`cat /proc/user_beancounters | grep " oomguarpages " | awk '{print $2}'` SWAP=$(($OOMGUAR-$PHYS)) echo echo Swapped out: $SWAP pages, or $(($SWAP*4096/1024)) KiB
Save that as e.g. scamram, chmod +x scamram and ./scamram
and you get an output like:
uid resource held maxheld barrier limit failcnt physpages 16994 29671 0 2147483647 0 oomguarpages 16995 29672 131072 2147483647 0 Swapped out: 0 pages, or 0 KiB
So essentially it is a good little method to see if any of your dedicated or guaranteed memory is being swapped out on the node due to over allocation.