VMware {code} Community
dikang85
Contributor
Contributor

How to get the free disk spaces(in KB or MB or GB) of a vm using the VIJava2 SDK

I know how to get the total disk spaces in KB of a vm, using the VirtualDisk.capacityInKB. But how to get the free spaces of the disk?

Thanks

Dikang

0 Kudos
3 Replies
lamw
Community Manager
Community Manager

To get this information, your VMs must have VMware Tools intalled and you can get various pieces of information within the guest:

http://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/vim.vm.GuestInfo.html

and specifically to your question, take a look at:

http://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/vim.vm.GuestInfo.DiskInfo...

I have a Perl script that extracts this and other things about your VI or vSphere environment: and

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

VMware Code Central - Scripts/Sample code for Developers and Administrators

If you find this information useful, please award points for "correct" or "helpful".

dikang85
Contributor
Contributor

Hi William,

Thank you very much for your information!

Is it impossible for me to get this information without the VMware tools? Because I need the information for lots of vm on ESXes, it will cost me a lot of time to install the Vmware tools for each vm...

Thanks

Dikang

0 Kudos
lamw
Community Manager
Community Manager

nope, this information is only exposed if you have VMware Tools and you can test this by running a query against a VM w/ and w/o VMware Tools to verify. If the VMs are all of one type, perhaps you may want to write something that connects directly against the guest or run something within the guest to query this information (WMI for Windows or shell script for UNIX/Linux).

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

VMware Code Central - Scripts/Sample code for Developers and Administrators

If you find this information useful, please award points for "correct" or "helpful".

0 Kudos