07 April, 2009

Timing VM Startup Script

In my previous post I eluded to creating a script for timing the starting of a virtual machine.

This is it, use at your leisure:


set i=0
while ( $i < starttime="`date" addr="" response="1" response ="=">> /dev/null
set response=$status
set stopTime=`date +%s`

set secs=`expr $stopTime - $startTime`
echo "startUp: $secs (secs)"

sleep 10
vmrun -T -h '' -u vmadmin -p 'vmadminpassword' stop "[standard] JltvWinXp/JltvWinXp.vmx"
set i=`expr $i + 1`

The script loops 5 times to get a crude sampling. Each iteration, the virtual machine is started then monitored via a ping until the VM is pingable. It then sleeps some 10 seconds before commanding the virtual machine to shutdown.

No comments: