Automation

 View Only
  • 1.  List Queue Depth for all the devices

    Posted Jul 30, 2020 01:16 PM

    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



  • 2.  RE: List Queue Depth for all the devices

    Posted Jul 30, 2020 01:27 PM

    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



  • 3.  RE: List Queue Depth for all the devices

    Posted Jul 30, 2020 02:16 PM

    LucD,

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



  • 4.  RE: List Queue Depth for all the devices

    Posted Jul 30, 2020 02:20 PM

    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



  • 5.  RE: List Queue Depth for all the devices

    Posted Jul 30, 2020 02:36 PM

    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



  • 6.  RE: List Queue Depth for all the devices

    Posted Jul 30, 2020 02:50 PM

    Both scripts are using the exact same line

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



  • 7.  RE: List Queue Depth for all the devices

    Posted Jul 30, 2020 03:11 PM

    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



  • 8.  RE: List Queue Depth for all the devices

    Posted Jul 30, 2020 03:16 PM

    That is not the script I posted earlier.



  • 9.  RE: List Queue Depth for all the devices

    Posted Jul 30, 2020 03:34 PM

    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)



  • 10.  RE: List Queue Depth for all the devices
    Best Answer

    Posted Jul 30, 2020 03:58 PM

    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



  • 11.  RE: List Queue Depth for all the devices

    Posted Jul 30, 2020 05:29 PM

    That worked. Thank you very much LucD. :smileyhappy: