2

On both Guest machine and host machine, I am using Ubuntu 12.04. As a hypervisor I am using KVM. I want to perform some experiments related to boot-storm and I have created all other scripts to create VM, delete VM and start VM. But I don't know how to measure boot time for each VM.

Though not necessary but it will be good if the boot time has one to one mapping to VM in some sense, by name or by mac address etc.

Boot time: I want to do ssh from host and when its successful I will consider that the VM has been booted up successfully.

The solution should be scalable as I want to perform experiment for 100-150 VMs.

Problems:

1) How to get the IP address of a guest VM from Host machine ?

2) Mapping of Domainname-> IP

3) Mapping of IP -> Boot time

A-B
  • 563
  • 2
  • 6
  • 17

2 Answers2

1

Here is an example how you can test if a machine is online using ping:

#!/bin/bash
# test-online.sh
ret=1
while [ $ret != 0 ]
do
  ping -c 1 $1 2>/dev/null
  ret=$?
done
exit 0

You can adapt this to use ssh by replacing the ping line with something like ssh $1 "echo", assuming you can connect to the machine without a password.

Using the above script (let's call it test-online.sh), you can start the machine and then measure the time using GNU time (the first argument of this script is the machine name):

#!/bin/bash
# start-and-time.sh
start-vm $1
/usr/bin/time -f "%E" ./test-online.sh $1

The output will be something like 1:23.52 which means your machine took 1 minute 23 seconds to boot.

If you want to measure the boot time of many machines, you can just call start-and-time.sh for every machine:

#!/bin/bash
mymachines=(machine1 machine2 machine3)
for machine in "${machines[@]}"
do
  echo -n "$machine "
  ./start-and-time.sh $machine &
done

which will give the following exemplary output:

machine1 1:53.23
machine2 2:42.42
machine3 0:42.42
morxa
  • 193
  • 1
  • 7
  • Thanks for your response. But this is trivial. Once you have IP address of VM , you can get the boot time. May be the question was a bit misleading, I have edited the question. – A-B Mar 01 '15 at 11:09
  • 5
    Ping tells you that the system is responding to ping, it doesn't mean it's booted and usable. – user9517 Mar 01 '15 at 11:12
  • Well using `ping` is just an example, you could also use `ssh` as explained. – morxa Mar 01 '15 at 11:14
  • Instead of ping I am using "until nc -vzw 2 $ip 22; do sleep 2; done 2>/dev/null". It will check on port number 22 i.e for ssh. and it working fine for me. – A-B Mar 02 '15 at 18:25
  • for sleep we can give some smaller value depending on the use case. – A-B Mar 02 '15 at 18:36
0

You can create a small service to install on all VMs and configure them to execute that service at whatever moment you consider your boot process to be complete.

That service can either hit an HTTP URL hosted by your benchmarking app (and telling its hostname and other stuff in the request data so the bench app knows which VM is which) or spit something out on a virtual serial port emulated by QEMU.

I would personally prefer the serial port approach, as it doesn't require networking (in case your VMs don't have any to begin with) and is a tiny bit more efficient than using the network stack (I know a few miliseconds of CPU time won't make any difference but whatever).