Virtualbox - check virtual machine status from command line


#1

Hi,

I would like to create a bash script to automatically check a virtualbox virtual machine’s status. I know how to check status from GUI bu what I need is a command line solution.

palco


#2

Dear palco,

we can use vboxmanage command to see the status

on you bash shell type following command

vboxmanage list runningvms

Hope so it will help you out

Thanks

bnhashmi


#3

Hi bnhashmi,

Your commands only shows VMs which are currently running. Is there a way to see a status of all VMs whether stopped, running, saved etc.?

thank you


#4

Hi bnhashmi,

Your commands only shows VMs which are currently running. Is there a way to see a status of all VMs whether stopped, running, saved etc.?

thank you

Dear atlas,

Please Use Following bash command.

VBoxManage list vms

Thanks


#5

Hi bnhashmi,

 VBoxManage list vms

the above will only list all virtual machines regardless of their status. The status is also not visible. I need to output all virtual machines and their status…

lubos


#6

Sorry Dear Atlas,

I Was busy in some task so here you go, hope so follwing commands will help you out with your task and also make you understand

In Real I was making a test environment for your issue.

If you will not register them using VBoxManage registervm they might not be visible in VBoxManage list vms command.

1st of all you have to register each virtual machine using following command if you are not getting list virtual machines by default in output.

VBoxManage registervm /home/bnhashmi\ VMs/CentOS-6.4-I386-1/CentOS-6.4-I386-1.vbox

Start Virtul machine

View Machine Status

VBoxManage list vms -l | grep -e ^Name: -e ^State | sed s/\ \ //g | cut -d: -f2-
VBoxManage startvm CentOS-6.4-I386-1

Save machine state.

VBoxManage startvm CentOS-6.4-I386-1

Save Virtual Machine state.

VBoxManage controlvm CentOS-6.4-I386-1 save

View Machine Status

VBoxManage list vms -l | grep -e ^Name: -e ^State | sed s/\ \ //g | cut -d: -f2-

Resume Machine

VBoxManage controlvm CentOS-6.4-I386-1 resume

View Machine Status

VBoxManage list vms -l | grep -e ^Name: -e ^State | sed s/\ \ //g | cut -d: -f2-

VBoxManage controlvm CentOS-6.4-I386-1 pause

View Machine Status

VBoxManage list vms -l | grep -e ^Name: -e ^State | sed s/\ \ //g | cut -d: -f2-

VBoxManage clonevm CentOS-6.4-I386-1 --name CentOS-6.4-I386-Clone --register

View Machine Status

VBoxManage list vms -l | grep -e ^Name: -e ^State | sed s/\ \ //g | cut -d: -f2-

Start Cloned VM

VBoxManage startvm CentOS-6.4-I386-Clone

VBoxManage list vms -l | grep -e ^Name: -e ^State | sed s/\ \ //g | cut -d: -f2-

Thanks And Regards,

bnhashmi


#7