This is another example and use case for using the vRops API to make some tasks easier. Let me set the scene. You have a large environment with maybe a 1000 datastores. Quite a few alerts in vRops for datastores that are full or about to run full. Like the pro you are, you have of course datastore clusters in use. Like so many others the storage team uses an automated storage tiering, which forces us to disable some SDRS stuff. For many that means that SDRS is a manual task which can be run in order to distribute the VMDKs smarter over the datastores in the datastore cluster. Automation has been disabled mostly for political reasons or because of legacy solutions.
If you are new to the hole vRops API – I did a blog post called vRops API consumed with Powershell Which covers some basics, but the example used here is just as simple, so you should be able to jump right in.
With this many alerts instead of focusing on the datastores them self, focusing on the datastore cluster will help reduce the time it takes to fix the issues. vRops doesn’t show this infomation on the alert and going through 20,50 or 100+ alerts will be very time consuming.
The output could look something like this:
Name Count ---- ----- Datastore_Cluster_01 3 Datastore_Cluster_02 22 Datastore_Cluster_03 18 Datastore_Cluster_04 4 Datastore_Cluster_05 41 Datastore_Cluster_06 12
vRops API – Working with Alerts
The script is simple – The first 22 lines is about creating the connection, on line 25 the script gets a list of 5000 alerts (and only 5000 – So if more alerts have been create in vRops, you wont get the full list). After that the script runs though every alert which is active and alert name matches “Datastore is running out of disk space” and gets the “parent” of the datastore, if the parent is a “StoragePod”. A “StoragePod” is what is normally referred to as a datastore cluster. Lastly the script groups the alerts based on the datastore cluster name and provides a count of how many datastores in the datastore cluster which have an active alert.
Now for the script – Enjoy