Page 1 of 1

"VBoxManage list vms --long" gives incorrect state

Posted: 2. Apr 2014, 15:50
by bgee22
Hello everyone -

I am working up some scripts which will report the status of virtual machines through the logwatch facility. After some work with sudo, I finally have it to the point where logwatch will incorporate the output of "VBoxManage list vms --long" into the daily report.

The problem I have is that the report is wrong! It lists every VM on the host as powered off. That is not true ... Most are actively running. The GUI manager shows the correct state for each VM.

I use VBox version 4.3.8 on 64-bit CentOS 6.

Any ideas?

Thanks - Bill Gee

Re: "VBoxManage list vms --long" gives incorrect state

Posted: 2. Apr 2014, 16:25
by Perryg
The problem I have is that the report is wrong! It lists every VM on the host as powered off. That is not true ... Most are actively running
If you run the list command using any other login than the one that owns the guest it will not show them as running. Reason is they are not running under the user if they did not start the guest.

Re: "VBoxManage list vms --long" gives incorrect state

Posted: 3. Apr 2014, 13:54
by bgee22
But that is not the case here. I *AM* running VBoxManage as the user who is also running the VMs.

I tried running VBoxManage as root, and it produced NO output at all. In this case I get output - it is just wrong.

I found this morning that the sudo command will not work either. It insists on running from a tty. When cron runs the logwatch scripts, there is no tty attached. ARGH!!! Why is this so hard? I just want an automated report every day telling me what the status is of the VMs! It is just basic management.

Bill Gee

Re: "VBoxManage list vms --long" gives incorrect state

Posted: 3. Apr 2014, 14:53
by Perryg
Well the cron job is not being run as you so that answers that. As for the other part I don't know what to tell you. I tested this and it reports the proper information for me.

Code: Select all

VBoxManage list vms --long | grep -e Name -e State
As for root or sudo I have already answered that.

Re: "VBoxManage list vms --long" gives incorrect state

Posted: 6. Apr 2014, 16:45
by bgee22
SOLVED. I figured it out.

The problem was that VirtualBox had lost contact with the running VMs. I discovered that every time I started a VM, within a few minutes a message would pop up saying "Creating process for virtual machine." Although the VM was running correctly, the VBox service could not talk to it. The "creating process" message would never go away, though it could be killed.

I found an old thread on this forum describing the message. Fixing it required rebooting the host machine.

From there I went back to the cron job. The cron job WAS running, but could not complete due to permissions. SUDO was not working when run from cron. The solution was to build a cron job directly in the account of the user running the VMs. This cron job directs output to a text file which is then picked up by logwatch.