VMware {code} Community
arpitmpatel13
Enthusiast
Enthusiast

How to get free disk space of VM/ESX using VI SDK

Hi all,

I am using VI sdk to collect performance data of Disk. in that, I want to collect free disk space for VM/ESX, which I am not able to collect using VI SDK or Virtual Center Server....I am able to collect perfomance data like disk usage (KBps) , bytes read/sec etc for both ESX and VM.... But not able to get free disk space counter....

I am using VI SDK 2.5, VC 2.5, and ESX 3.

Can Any one Plz help about this...

Thanks in advance..

Reply
0 Kudos
4 Replies
admin
Immortal
Immortal

Hi,

In order to retrieve the disk space of VM, you can get the "guest.disk.freeSpace" property of the Virtual Machine to get the free space on the disk, in bytes.

For ESX, you can use get the "datastore" property of the HostSystem to get the number of datastores available with the host. Now, you can sum up the "info.freeSpace" property to get the total free space (in bytes) available with the ESX.

Hope the above information helps.

Regards,

Seemanki

Reply
0 Kudos
dsubram
Enthusiast
Enthusiast

This information can't be retrieved directly. We need to traverse thru the filesystem details to get space left on the disk.

HostSystem -> HostFileSystemVolumeInfo->[HostFileSystemMountInfo[]|http://www.vmware.com/support/developer/vc-sdk/visdk25pubs/ReferenceGuide/vim.host.FileSystemMountInfo.html] ->[HostFileSystemVolume|http://www.vmware.com/support/developer/vc-sdk/visdk25pubs/ReferenceGuide/vim.host.FileSystemVolume.html]

In addition you should use below details too,

Typically a FileSystem is exposed as a datatore

See DatastoreInfo

See HostVmfsVolume

See HostNasVolume

See HostLocalFileSystemVolume

You DataStoreInfo object to get mode details.

Reply
0 Kudos
arpitmpatel13
Enthusiast
Enthusiast

Thanks alot...

It works...

Reply
0 Kudos
tos2k
Expert
Expert

Hi!

Just one addition: The only issue "free disk space" has, is a missing link between the guest info and "the rest" of the data. This makes it impossible to see which vm has how much empty disk space where.

U can see how much disk space is left on a partition, seen from within a VM. U cannot see where this partition resides physically as the link between partition and a virtual disk is missing (even a link to layout->disk->key would help here).

So you can find out how much free space is left on a datastore, as how much space is left within a VM. But you can not (easily) find out if the datastore for a given VM-partition has enough space to expand the virtual disk the partition resides on.

Tos2k

Reply
0 Kudos