VM DiskFree Example

The toolkit already comes with some great samples files that demonstrates how to do some basic discovery, virtual machine and host operations and how to query performance counters.

Well I have made an extra example that you might want to use. The SDK funny enough exposed more functionality then VirtualCenter Client does, I know it is strange, but true. For example the SDK allows you to read out information about the virtual disks seen from within the virtual machine. So you can see what partitions/volumes are on the virtual disk, how big they are and how much free space is available. The current Virtual Center Client does not report this information to you… Till now 🙂

My example program reads out the information about all running virtual machines and report the information in a custom field. The program automatically creates the custom fields if they do not exists yet, so all you have to do is set the right username, password and ip to your virtual center and run the script (on a system that has the VI Perl Toolkit installed).

Example of reporting disk usage in custom fields

In the example above you see the custom fields and the disk usage of the virtual machines. You can sort them in the interface, the only thing ‘missing’ is that you can not setup an Alarm based on the contents of a custom field. Else you could have even triggered an alarm 🙂

Just run the script every hour or so and you can keep track of the disk usage 🙂

You can download the script here: VI3_diskfree