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:


#!/bin/csh

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

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

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

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: