Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Is there an API for Java in getting the CPU usage of a VM in KVM? I want to know how I could get the CPU usage of a guest (from the host's perspective) using Java.

Also, does anybody know where I could find the source of virt-manager so I could learn how it gets/computes the CPU usage it displays in Virtual Machine Manager?

share|improve this question

2 Answers 2

Perhaps one of the methods in Interface OperatingSystemMXBean be adapted to what you are looking for.

See http://docs.oracle.com/javase/7/docs/jre/api/management/extension/com/sun/management/OperatingSystemMXBean.html

share|improve this answer
1  
Thank you sir. Will look that up. –  user3752288 Jul 6 at 2:59

I do not know of any Java APIs which expose KVM but the source for virt-manager is accessible here in the official Git repo.

Additionally I'd look to the libvirt API for interacting with KVM or any other virtualization technology. Specifically there are Java bindings to the libvirt API.

share|improve this answer
    
Thank you sir. I've been to that website (Git repo of virt-manager) a lot of times since I've been researching for weeks but I couldn't manage to understand how the site works. Is it all right if you could briefly explain how it works? Thanks a lot sir. –  user3752288 Jul 6 at 17:41
    
@user3752288 - here's a link to the latest trunk version of the code base: git.fedorahosted.org/cgit/virt-manager.git/snapshot/…. It's tarred up for easier download. –  slm Jul 6 at 17:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.