The last topic that I would like to explore before concluding my VSAN API blog series are some of the advanced VSAN disk statistics that are available for either troubleshooting or informational purposes. One such statistic that would be handy to know about is the number of VSAN Components per ESXi host, which I have already demonstrated in my recent VSAN configuration maximum query script and VSAN PowerCLI vCheck Plugins.
These disk statistics are made available through the VSAN InternalSystem manager and using the QueryPhysicalVsanDisks() vSphere API method, we can either retrieve all or a specific set of properties for each ESXi host. I have created a sample vSphere SDK for Perl script called vsanDiskStatsQueries.pl that will demonstrate the use of this API.
Disclaimer: These scripts are provided for informational and educational purposes only. It should be thoroughly tested before attempting to use in a production environment.
Here is an example of running the script against a VSAN Cluster which will produce the number of VSAN components for each ESXi host:
./vsanDiskStatsQueries.pl --server vcenter55-1.primp-industries.com --username root --cluster VSAN-Cluster
If we take a look at the script, you will notice we filtered on two specific properties: lsom_objects_count and owner. One thing to note is the output for this method is JSON string, so you will need to parse the output accordingly.
The owner property indicates the UUID of a specific ESXi host and the lsom_objects_count represents the number of VSAN components. To be able to identify the particular ESXi host and compare it to the owner property, we use the QueryHostStatus() API which was discussed in Exploring VSAN APIs Part 5. Once we have a match for the current ESXi host, we simply extract the lsom_objects_count property which I use a simple hash table to keep track of the results and display it at the very end of the script.
This concludes my 9-part series of exploring the new VSAN APIs. Hopefully for those of you who followed the series have enjoyed it, I know I definitely had fun learning about the new APIs and how you can automate every aspect of VSAN from a scripting and programmatic perspective.
- Exploring VSAN APIs Part 1 – Enable VSAN Cluster
- Exploring VSAN APIs Part 2 – Query available SSDs
- Exploring VSAN APIs Part 3 – Enable VSAN Traffic Type
- Exploring VSAN APIs Part 4 – VSAN Disk Mappings
- Exploring VSAN APIs Part 5 – VSAN Host Status
- Exploring VSAN APIs Part 6 – Modifying Virtual Machine VM Storage Policy
- Exploring VSAN APIs Part 7 – VSAN Datastore Folder Management
- Exploring VSAN APIs Part 8 – Maintenance Mode
- Exploring VSAN APIs Part 9 – VSAN Component count
- Exploring VSAN APIs Part 10 – VSAN Disk Health