I use https://www.virtualbox.org for all of my home computer virtualization needs. I have a number of virtual machine guests which spend most of their time off, and when I do power them on I have to spend some time updating them to bring them current with software and security updates. What I would like to do eventually is integrated these virtual machines with my regular https://www.saltstack.com/ based updates of my computers which are on-line most of the time.
Before I can fully automate things I need to figure out how to list all available virtual guest, identify whether they are currently on or off, power them on and shut them down from the command line. VirtualBox provides the VBoxMange for this purpose and this post is simply to put the commands all in one place where I can find them.
List Current Guest VMs
Returns a list of VM names and UUIDs:
Returns a list of powered on VMs and UUIDs:
Get Power State of VMs
Returns a listing of power states of the VMs.
Power On VMs
Resulting output:
Alternate –types for start up include headless and gui.
Pause VMs
Resume VMs
Power Off VMs
In order for the above to work, the guest must be configured to respond to ACPI power button presses by shutting down gracefully.
VM metricts
To collect and display metrics for a given vm, specify period in seconds for the collection and number of last samples to retain. The following exampl callects all metrics for a vm every three seconds and reains the five most recent sample values.
The following example collects and displays only a subset of available metrics related to CPU usage and RAM.
Chrls is currently a technology transformation leader at one of the oldest American investment banking services holding companies, headquartered in New York City. Previous roles at current employer include project manager, front office support, retail and enterprise global Windows server support. Currently residing in Tennessee on the Cumberland Plateau and enjoying life, family and open source.