How to Disable Storage I/O Stats Collection with PowerCLI or vRO

I recently came across a thread asking about how to disable Storage I/O Statistics Collection using PowerCLI. The thread referenced this article by Michael Webster: Disable SIOC IO Metrics Collection For Auto Tiering Storage Systems. In one of the comments, someone asked about using PowerCLI.. Unfortunately there was no answer there so I thought - I might be able to figure this out! With regards to checking that box, I can’t say whether it’s a good idea or not, my purpose here was just to illustrate how to do it via PowerCLI and vRO.

Goal

The overall goal of this post is to teach you how to Disable Storage I/O Statistics Collection using PowerCLI… more importantly, I will step you through my approach as a vRO guy trying to figure out how to create some PowerCLI code to accomplish the task. Once I’m done, I’ll also provide a simple vRO workflow to do the same…

I’m a vRO guy with MINIMAL PowerShell and PowerCLI experience. One thing I AM familiar with is the fact that the current version of Onyx works with the vSphere Web Client and is able to produce PowerCLI code based on recorded actions in the client. I’m still waiting for some developer-type people to get this tool updated to output vRO Javascript like the old version did….ok.. enough babbling… let’s get on with how to actually do this.

First off, make sure you have Onyx installed in your vSphere Web Client. Then, proceed as follows…

vSphere Web Client - View Datastore General Settings

As seen in the screenshot, navigate to the Datastore you wish to modify. It’s important to get the client to the object you wish to modify BEFORE starting the ONYX recording tool in order to minimize the amount of code that gets generated. As you’ll see, it generates quite a bit!

  • Now, Click the Record Button at the top of your vSphere Web Client
  • Next, Click EDIT next to Datastore Capabilities

vSphere Web Client - Adjust Desired Settings

vSphere Web Client - Adjust Desired Settings
  • Note that the red circle is now a red squre (stop) to indicate that Onyx is recording your actions…
  • Adjust the settings as desired.. for this article, we are focusing on Disable Storage I/O statistics collection so enable the checkbox there
  • Click OK when Done
  • Click the Onyx icon to the right of the Red square at the top of the client

vSphere Web Client Onyx UI

vSphere Web Client Onyx UI
  • Click the “Stop” button – once clicked, the button changes to “Start” as shown in the screenshot
  • Once recording has stopped, the code will appear in the text area

As you can see, quite a bit of code got generated:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# ------- ConfigureDatastoreIORM_Task -------
$datastore = New-Object VMware.Vim.ManagedObjectReference
$datastore.value = 'datastore-61'
$datastore.type = 'Datastore'
$spec = New-Object VMware.Vim.StorageIORMConfigSpec
$spec.percentOfPeakThroughput = 95
$spec.statsCollectionEnabled = $false
$spec.enabled = $false
$spec.congestionThreshold = 30
$spec.congestionThresholdMode = 'automatic'
$spec.statsAggregationDisabled = $true
$_this = Get-View -Id 'StorageResourceManager-StorageResourceManager'
$_this.ConfigureDatastoreIORM_Task($datastore, $spec)

# ------- getRuntime -------
$_this = Get-View -Id 'HostSystem-host-129'
$_this.getRuntime()

# ------- getContent -------
$_this = Get-View -Id 'ServiceInstance-ServiceInstance'
$_this.getContent()

# ------- getCapabilities -------
$_this = Get-View -Id 'HostDatastoreSystem-datastoreSystem-129'
$_this.getCapabilities()

# ------- getRuntime -------
$_this = Get-View -Id 'HostSystem-host-129'
$_this.getRuntime()

# ------- getContent -------
$_this = Get-View -Id 'ServiceInstance-ServiceInstance'
$_this.getContent()

# ------- getCapabilities -------
$_this = Get-View -Id 'HostDatastoreSystem-datastoreSystem-129'
$_this.getCapabilities()

Okay, there’s a bunch of stuff on there statically coded based on my selections in the vSphere Web Client…Based on what we actually want here, it looks like the most relevant bit of code is that top chunk, everything after that seems irrelevant so were are now left with:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# ------- ConfigureDatastoreIORM_Task -------
$datastore = New-Object VMware.Vim.ManagedObjectReference
$datastore.value = 'datastore-61'
$datastore.type = 'Datastore'
$spec = New-Object VMware.Vim.StorageIORMConfigSpec
$spec.percentOfPeakThroughput = 95
$spec.statsCollectionEnabled = $false
$spec.enabled = $false
$spec.congestionThreshold = 30
$spec.congestionThresholdMode = 'automatic'
$spec.statsAggregationDisabled = $true
$_this = Get-View -Id 'StorageResourceManager-StorageResourceManager'
$_this.ConfigureDatastoreIORM_Task($datastore, $spec)

Alright, now, looking through the settings here, we can comment out several lines that are for other settings (unless you also want the ability to set those as well), giving us:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# ------- ConfigureDatastoreIORM_Task -------
$spec = New-Object VMware.Vim.StorageIORMConfigSpec
# $spec.percentOfPeakThroughput = 90
$spec.statsCollectionEnabled = $false
# $spec.enabled = $false
# $spec.congestionThreshold = 30
# $spec.congestionThresholdMode = 'automatic'
# $spec.statsAggregationDisabled = $false
$_this = Get-View -Id 'StorageResourceManager-StorageResourceManager'
$_this.ConfigureDatastoreIORM_Task($datastore, $spec)

Okay, we’re getting closer now, but there are still static values in here… after a few minutes of googling around various blog sites, I updated the code to the following:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Provide vCenter Host and Credentials
$VCUser = "specify-vcenter-user-here"
$VCPass = "specify-vcenter-pw-here"
$VCIP = "specify-vcenter-ip-or-fqdn-here"
# Set Datastore Name:
$DSName = "specify-datastore-name-here"

$connection = Connect-VIServer -Server $VCIP -User $VCUser -Password $vcpass -WarningAction SilentlyContinue
$datastore = Get-Datastore -Name $DSName
$dsView = Get-View $datastore
$dsMoRef = $dsView.MoRef

# ------- ConfigureDatastoreIORM_Task -------
$spec = New-Object VMware.Vim.StorageIORMConfigSpec
# $spec.percentOfPeakThroughput = 90
$spec.statsCollectionEnabled = $false
# $spec.enabled = $false
# $spec.congestionThreshold = 30
# $spec.congestionThresholdMode = 'automatic'
# $spec.statsAggregationDisabled = $false
$_this = Get-View -Id 'StorageResourceManager-StorageResourceManager'
$_this.ConfigureDatastoreIORM_Task($dsMoRef, $spec)

We now should have a working script… so, go back to your datastore and uncheck the box… then try running your new script!

Launch your vRO Client

Launch vRO Client

There aren’t any out of the box workflows or actions that do this that I’m aware of… but, looking at the code above, I see a couple really important objects:

  • StorageResourceManager
  • StorageIORMConfigSpec

… and then, the various properties of the spec …

and a method to apply the spec:

  • ConfigureDatastoreIORM_Task()

So, based on that, use the API explorer in vRO to look for those Scriptable Objects..

Review the API Explorer

Review the API Explorer
  • At the top of your vRO Client, click on Tools - > API Explorer
  • Enter ConfigureDatastore in the Containing text box
  • Click SEARCH
  • Inspect the results in the bottom pane, and double-click on the entry with configureDatastoreIORM_Task in it
  • You should be taken to that method in the tree on the left
  • Note that the method is tied to the VcStorageResourceManager object - slightly different name (preceded by Vc) than the PowerCLI equivalent

Okay, this is good, things are aligning to what we found in PowerCLI - let’s create a simple workflow!

Workflow: Disable IO Stats Collection

Workflow - Disable I/O Stats Collection
Create a new workflow with:

  • Scriptable Task -. Name the scriptable task Disable IOStats Collection
  • Action –> vim3WaitTaskEnd

Scriptable Task: Disable IOStats Collection

Scriptable Task: Disable IOStats Collection
We’ll keep this simple so add a single input to the Scriptable task to pass in the Datastore object we wish to modify:

  • Select the Disable IOStats Collection Scriptable task
  • Make sure the IN tab is selected
  • Click the button to add a new parameter (when prompted, click the “Create parameter/attribute in workflow” link in the Chooser window that comes up
  • In the Create parameter window, name the parameter datastore
  • Use the Filter box to filter on “datastore”
  • Scroll through the Type box and verify that VC:Datastore is selected
  • Set the option to Create workflow INPUT PARAMETER with the same name
  • Click OK when done
  • Now, on the OUT Tab, create a new ATTRIBUTE named “task” of type VC:Task
  • Click on the Scripting tab when done

Scriptable Task: Disable IOStats Collection - Script

Fortunately, Onyx did the hardest work for us earlier - even though it generated PowerCLI code, it identified the important objects and methods required to accomplish the task at hand. Based on that earlier code and a bit of experience with vRO JavaScript, I managed to convert the code to vRO-ready code as follows:

1
2
3
4
var storageResourceManager = datastore.sdkConnection.storageResourceManager;
var spec = new VcStorageIORMConfigSpec();
spec.statsCollectionEnabled = false;
var task = storageResourceManager.configureDatastoreIORM_Task(datastore, spec);

The first line sets oup our Storage manager. Using the API Explorer, I was able to determine that the StorageManager was a property of the SdkConnection object - AND - the SdkConnection is typically a property of most vCenter objects, such as a Datastore!

The next line Initializes a new object that will be used for the vCenter Storage IO Resource Manager Configuration Spec (VcStorageIORMConfigSpec).

Line 3 sets the statsCollectionEnabled value to false.

The final line runs the configureDatastoreIORM_Task methond, passing in the datastore object and the config spec. It returns a VC:Task object (this can be determined by inspecting the method using the API Explorer) and assigning the resulting object to the task variable.

Next, we need to wait for that task to complete - that is handled by the action we added to the workflow…

Scriptable Task: Disable IOStats Collection - vim3WaitTaskEnd bindings

Scriptable Task: Disable IOStats Collection - vim3WaitTaskEnd bindings
  • Now, we need to bind the inputs and outputs for the vim3WaitTaskEnd action so select it
  • Select the Visual Binding tab
  • Drag the task in from the center section to the bottom left
  • Release on the existing In Attribute : task (VC:Task)
  • Drag Progress to the In Attributes box as well, initially, the “progress” attribute won’t be there so release the attribute in the white-space of the box. You’ll then be prompted to create the attribute so just click OK
  • Drag pollRate to the In Attributes box to create and bind that attribute just like the progress attribute
  • On the right side, drag actionResult down to the Out Attributes box and release, click OK to create that attribute
  • Finally, click Validate to make sure the workflow is ready
  • Click Save and close when done

Our next step is to test the workflow and confirm it works. Before proceeding to the next step, be sure that you have UNCHECKED the box if you had checked it manually or via PowerCLI as shown earlier in this article.

Test the Disable IOStats Collection Workflow

Test the Disable IOStats Collection Workflow
Run the workflow, select the Datastore you wish to take action and and Submit.

When done, check vSphere Web Client and confirm that the box is checked!

Summary

While this article focused on a specific use case, the approach taken here can be used for many other vCenter tasks as well. I sincerely hope you have gained a new appreciation for the Onyx client, PowerCLI, and vRealize Orchestrator (vRO).