Viewing Unix Free Memory OpenVZ VPS

Unfortunately for virtualized dedicated servers (VDS or VPS) the free command is generally not a good indication of available memory as it reports on the entire system, not memory alloted to your virtual system.

Executing the command below will result in output similar to below:

Used Memory: 329MB Total Memory: 512MB

# `awk '/privvmpages/ {printf "Used Memory: %dMB\n Total Memory: %dMB\n", $2/1024*4, $4/1024*4}' /proc/user_beancounters`

For those of you who do not want to type that large command line every time grab it in a simple script using:

# wget http://vision-media.ca/files/tools/openvzmem

And executing using:

# ./openvzmem

Or creating and executing an alias

# alias openvzmem="/root/openvzmem"
# openvzmem