[vbox-dev] VirtualBox monitor CPU usage of virtual machine

Adrian Marogel adrian.marogel at gmail.com
Sun Apr 25 15:08:53 GMT 2010

I asked you this because I've used before a vmware sdk and that had the first
two problems resolved in its API. I just wanted to know if this was possible
with VirtualBox.

I need an answer for the above, because I'm trying to run some distributed
calculations and use the following logic:
- I have a LAN of hosts running VirtualBox. I need to monitor the CPU usage of
the virtual machine's CPU and if that is above a certain threshold, say 90%,
then the next step would be to power on another virtual machine in the LAN,
after querying the hosts for available resources.

Do you have any ideas on how to accomplish this ? 

Also, a fourth question, is there a way to limit the host's CPU usage by virtual
machines, so that if the virtual machine's CPU is 90%, the host CPU would be
much lower than that?

Note: I want to do all of these operations using the programmer approach, not
the sys-admin one, as I do want to write (Java) programs that would automate the
whole process.

My initial configuration is: 
All hosts run Linux (Ubuntu) with Linux virtual machines, although they could
run Windows with Linux virtual machines.

My solution for this was the following: 

Problem #1: I would SSH to login to the guest machine and then use an utility
like 'top' to monitor the CPU usage

Problem #2: I really haven't figured it out yet, because if I use the Linux
'free' utility, that doesn't guarantee that the returned result is accurate
enough for use. For example, on a system with 2 GB of memory, 'free' could
return that there are about 300mb left, because of all the caching done and the
system would still be able to power on a virtual machine that has 512mb of RAM.
So I don't really know how to resolve this issue.

Problem #3: I would also use SSH to login into the host machine and then use
something like VBoxManage for power on. Is there any functionality closer to
'teleporting' that would do this for me in VirtualBox or in the SDK?

Problem #4: I found some Linux program called CPULIMIT that would do the job. Is
there some other way I could do this?

For SSH logins, I would use the Ganymed Java library, for the remote execution
of programs.

But I still don't have ideas for Problem #2.

I posted the above to have a clearer idea about what I need to accomplish and
what solutions I came accross.

I'm waiting for your feedback, if you have other (more elegant) solutions.


More information about the vbox-dev mailing list