Advertisement
Guest User

Untitled

a guest
May 23rd, 2015
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. host = RbConfig::CONFIG['host_os']
  2.  
  3. # Give VM 1/4 system memory & access to all cpu cores on the host
  4. if host =~ /darwin/
  5. cpus = `sysctl -n hw.ncpu`.to_i
  6. # sysctl returns Bytes and we need to convert to MB
  7. mem = `sysctl -n hw.memsize`.to_i / 1024 / 1024 / 4
  8. elsif host =~ /linux/
  9. cpus = `nproc`.to_i
  10. # meminfo shows KB and we need to convert to MB
  11. mem = `grep 'MemTotal' /proc/meminfo | sed -e 's/MemTotal://' -e 's/ kB//'`.to_i / 1024 / 4
  12. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement