简体   繁体   中英

I have to find time taken to register,run vm by euca commands using shell script

I have to find time taken:

  1. To register image (may be found by using time command)
  2. Time taken for running (pending to running state).
  3. Time to login (may be found by using time command)

I don't know how to find this interval time as I need to check state of VM.

You can try the following one-liner to obtain the time taken by an instance to change it's state from pending to running,

INS=$( euca-run-instances -k sshlogin -t m1.xlarge emi-F51D3A55 \
| grep INSTA | cut -f 2 ); time while(true); \
do if \[ $( euca-describe-instances $INS | grep INSTANCE \
| cut -f 6 ) = "pending" \]; \
then euca-describe-instances $INS; else break; fi; done

This should be reusable for other two as well.

By changing the rc.local file, we can make the VM perform some actions just when it becomes running . You could possibly save the time instant at which it becomes running in a file inside the VM itself. By this you won't have to keep polling the state of the VM. Once the VM is up, you will have the time instant at which is became running .

Hope this helps you out.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM