VMware Cloud Community
ganapa2000
Hot Shot
Hot Shot
Jump to solution

List Queue Depth for all the devices

Hi,

Using the below script, I am able to get the queue depth for Datastore devices, how can I get the queue depth for all the devices (Datastores and RDMs) starting with naa.62444*

Please help

Script

$clusterName = get-cluster | Select -Expandproperty Name

$report = @()

Get-Cluster -Name $clusterName -PipelineVariable cluster |

Get-VMHost -PipelineVariable esx |

ForEach-Object -Process {

    $esxcli = Get-EsxCli -VMHost $esx -V2

    $esxcli.storage.vmfs.extent.list.invoke() | %{

        $obj = $esxcli.storage.core.device.list.CreateArgs()

        $obj.device = $_.DeviceName

        $path = $esxcli.storage.core.path.list.Invoke($obj)

        $esxcli.storage.core.device.list.Invoke($obj) |

        ForEach-Object -Process {

            $dev = $_

            $ds = (Get-Datastore -RelatedObject $esx) |

                where{$_.ExtensionData.Info.Vmfs.Extent.diskname -contains $dev.Device}

            $report += Add-Member -InputObject $_ -MemberType NoteProperty -Name vCenter -Value (([uri]$esx.ExtensionData.Client.ServiceUrl).Host) -PassThru |

                Add-Member -MemberType NoteProperty -Name Cluster -Value $cluster.Name -PassThru |

                Add-Member -MemberType NoteProperty -Name VMHost -Value $esx.Name -PassThru |

                Add-Member -MemberType NoteProperty -Name Datastore -Value $ds.Name -PassThru |

                Add-Member -MemberType NoteProperty -Name LUN -Value (($path.LUN | Sort-Object -Unique) -join '|') -PassThru

        }

    }

}

$report

1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Ah, I think I found the issue.

The script started from the vmfs.extent list, hence only datastores.

Try this variation.

$match = '^naa.62444'

$report = @()

Get-Cluster -PipelineVariable cluster |

Get-VMHost -PipelineVariable esx |

ForEach-Object -Process {

    $esxcli = Get-EsxCli -VMHost $esx -V2

    $esxcli.storage.core.device.list.invoke() |

    where{$_.Device -match $match} |

    ForEach-Object -Process {

        $obj = $esxcli.storage.core.device.list.CreateArgs()

        $obj.device = $_.Device

        $path = $esxcli.storage.core.path.list.Invoke($obj)

        $esxcli.storage.core.device.list.Invoke($obj) |

        ForEach-Object -Process {

            $dev = $_

            $ds = (Get-Datastore -RelatedObject $esx) |

                where{$_.ExtensionData.Info.Vmfs.Extent.diskname -contains $dev.Device}

            $report += Add-Member -InputObject $_ -MemberType NoteProperty -Name vCenter -Value (([uri]$esx.ExtensionData.Client.ServiceUrl).Host) -PassThru |

                Add-Member -MemberType NoteProperty -Name Cluster -Value $cluster.Name -PassThru |

                Add-Member -MemberType NoteProperty -Name VMHost -Value $esx.Name -PassThru |

                Add-Member -MemberType NoteProperty -Name Datastore -Value $ds.Name -PassThru |

                Add-Member -MemberType NoteProperty -Name LUN -Value (($path.LUN | Sort-Object -Unique) -join '|') -PassThru

        }

    }

}

$report | Select device,LUN,datastore


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

10 Replies
LucD
Leadership
Leadership
Jump to solution

You can add a Where-clause.
LUN that do not belong to a datastore, will have the Datastore property empty.

$match = '^naa.62444'

$report = @()

Get-Cluster -PipelineVariable cluster |

Get-VMHost -PipelineVariable esx |

ForEach-Object -Process {

    $esxcli = Get-EsxCli -VMHost $esx -V2

    $esxcli.storage.vmfs.extent.list.invoke() | %{

        $obj = $esxcli.storage.core.device.list.CreateArgs()

        $obj.device = $_.DeviceName

        $path = $esxcli.storage.core.path.list.Invoke($obj)

        $esxcli.storage.core.device.list.Invoke($obj) |

        where{$_.Device -match $match} |

        ForEach-Object -Process {

            $dev = $_

            $ds = (Get-Datastore -RelatedObject $esx) |

                where{$_.ExtensionData.Info.Vmfs.Extent.diskname -contains $dev.Device}

            $report += Add-Member -InputObject $_ -MemberType NoteProperty -Name vCenter -Value (([uri]$esx.ExtensionData.Client.ServiceUrl).Host) -PassThru |

                Add-Member -MemberType NoteProperty -Name Cluster -Value $cluster.Name -PassThru |

                Add-Member -MemberType NoteProperty -Name VMHost -Value $esx.Name -PassThru |

                Add-Member -MemberType NoteProperty -Name Datastore -Value $ds.Name -PassThru |

                Add-Member -MemberType NoteProperty -Name LUN -Value (($path.LUN | Sort-Object -Unique) -join '|') -PassThru

        }

    }

}

$report


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

LucD,

where clause works but I am unable to get the information about the devices which are not part of Datastores in the output

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

It should show the LUN that are not part of a Datastore with an empty Datastore property.

All other LUNs that pass the Canonicalname test are shown.

At least in my environment


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

LucD,

using the below script, I can get the all the devices that are datastores and non-datastores. but I am not sure, what I need to change in the previous script.

$esx_hosts = Get-VMHost 10.10.10.124

$report = foreach($esx_host in $esx_hosts){

$esxcli=get-esxcli -VMHost $esx_host -V2

$ds_list = $esxcli.storage.core.device.list.invoke()

foreach ($ds1 in $ds_list) {

$arguments3 = $esxcli.storage.core.device.list.CreateArgs()

$arguments3.device = $ds1.device

$esxcli.storage.core.device.list.Invoke($arguments3) | select Device,DeviceMaxQueueDepth,NoofoutstandingIOswithcompetingworlds

}

}

$report

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Both scripts are using the exact same line

$esxcli.storage.core.device.list.Invoke($obj)


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

LucD,

After making the below changes, I am getting the blank output

$match = '^naa.624a937'

$report = @()

Get-Cluster -PipelineVariable cluster |

Get-VMHost -PipelineVariable esx |

ForEach-Object -Process {

    $esxcli = Get-EsxCli -VMHost $esx -V2

    $ds_list = $esxcli.storage.vmfs.extent.list.invoke() | %{

    foreach ($ds1 in $ds_list) {

        $obj = $esxcli.storage.core.device.list.CreateArgs()

        $obj.device = $ds1.DeviceName

        $path = $esxcli.storage.core.path.list.Invoke($obj)

        $esxcli.storage.core.device.list.Invoke($obj) |

       where{$_.Device -match $match} |

        ForEach-Object -Process {

            $dev = $_

            $ds = (Get-Datastore -RelatedObject $esx) |    where{$_.ExtensionData.Info.Vmfs.Extent.diskname -contains $dev.Device}

            $report += Add-Member -InputObject $_ -MemberType NoteProperty -Name vCenter -Value (([uri]$esx.ExtensionData.Client.ServiceUrl).Host) -PassThru |

                Add-Member -MemberType NoteProperty -Name Cluster -Value $cluster.Name -PassThru |

                Add-Member -MemberType NoteProperty -Name VMHost -Value $esx.Name -PassThru |

                Add-Member -MemberType NoteProperty -Name Datastore -Value $ds.Name -PassThru |

                Add-Member -MemberType NoteProperty -Name LUN -Value (($path.LUN | Sort-Object -Unique) -join '|') -PassThru

        }

    }

}

}

$report

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

That is not the script I posted earlier.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

sorry LucD. Why am I unable to get the device queue depth details in the output which are unused (free devices or RDMs). The first script which you provided works for devices which has Datastores created but I am unable to get output for devices which are non Datastores (free or RDMs)

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Ah, I think I found the issue.

The script started from the vmfs.extent list, hence only datastores.

Try this variation.

$match = '^naa.62444'

$report = @()

Get-Cluster -PipelineVariable cluster |

Get-VMHost -PipelineVariable esx |

ForEach-Object -Process {

    $esxcli = Get-EsxCli -VMHost $esx -V2

    $esxcli.storage.core.device.list.invoke() |

    where{$_.Device -match $match} |

    ForEach-Object -Process {

        $obj = $esxcli.storage.core.device.list.CreateArgs()

        $obj.device = $_.Device

        $path = $esxcli.storage.core.path.list.Invoke($obj)

        $esxcli.storage.core.device.list.Invoke($obj) |

        ForEach-Object -Process {

            $dev = $_

            $ds = (Get-Datastore -RelatedObject $esx) |

                where{$_.ExtensionData.Info.Vmfs.Extent.diskname -contains $dev.Device}

            $report += Add-Member -InputObject $_ -MemberType NoteProperty -Name vCenter -Value (([uri]$esx.ExtensionData.Client.ServiceUrl).Host) -PassThru |

                Add-Member -MemberType NoteProperty -Name Cluster -Value $cluster.Name -PassThru |

                Add-Member -MemberType NoteProperty -Name VMHost -Value $esx.Name -PassThru |

                Add-Member -MemberType NoteProperty -Name Datastore -Value $ds.Name -PassThru |

                Add-Member -MemberType NoteProperty -Name LUN -Value (($path.LUN | Sort-Object -Unique) -join '|') -PassThru

        }

    }

}

$report | Select device,LUN,datastore


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

ganapa2000
Hot Shot
Hot Shot
Jump to solution

That worked. Thank you very much LucD. Smiley Happy

Reply
0 Kudos