Code Snippets
Generate many kickstarted (CentOS) Linux Xen VMs.
In this example, we generate 20 VMs named sux_01 through sux_20
#!/bin/sh
count=100
while [ $count -ne 120 ] ; do
count=`expr $count + 1`
n=sux_${count:1}
virt-install -l http://kickstart.tripadvisor.com/install/centos/5/os/x86_64/ -p -x ks=http://kickstart.tripadvisor.com/install/tripadvisor/centos/5/xen/x86_64/kickstart.conf -n $n -r 4608 --vcpus=2 -f /var/lib/xen/images/$n.dsk -s 60 --nographics --noautoconsole
done
List various facts about actual and potential allocation of RAM to xen VMs
See how much RAM is allocated to active Xen VMs, how many are potentially allocated to VMs auto-started and how much physical RAM is in the machine.
#!/bin/bash
echo RAM currently allocated to active VMs \(in gigabytes\):
xm list | grep -v Mem\(MiB\) | awk 'BEGIN{total=0} {total += $3 / 1024} END{print total}'
echo RAM allocated to potential VMs from /etc/xen/auto \(in gigabytes\):
cat /etc/xen/auto/* | grep maxmem | awk 'BEGIN{total=0} {total += $3 / 1024} END{print total}'
echo Amount of physical RAM \(in gigabytes\):
xm info|grep total_memory|awk '{print $3 / 1024}'