VMware Cloud Community
devinder_lamba1
Contributor
Contributor

vSAN performance metrics are not retrieved using powercli

Tried to get the vsan performance metrics in couple of ways using the powercli

Connected using following cli - Connect-VIServer -Server <MyServer>

Method-1

Function Get-VSANPerformanceStat {

<#

    .NOTES

    ===========================================================================

     Created by:    William Lam

     Organization:  VMware

     Blog:          www.virtuallyghetto.com

     Twitter:       @lamw

        ===========================================================================

    .DESCRIPTION

        This function retreives a particlular vSAN Performance Metric

        from a vSAN Cluster using vSAN Management APIs

    .PARAMETER Cluster

        The name of the vSAN Cluster

    .PARAMETER StartTime

        The start time to scope the query (format: "04/23/2017 4:00")

    .PARAMETER EndTime

        The end time to scope the query (format: "04/23/2017 4:10")

    .PARAMETER EntityId

        The vSAN Management API Entity Reference. Please refer to vSAN Mgmt API docs

    .PARAMETER Metric

        The vSAN performance metric name for the given entity

    .EXAMPLE

        Get-VSANPerformanceStat -Cluster VSAN-Cluster -StartTime "04/23/2017 4:00" -EndTime "04/23/2017 4:05" -EntityId "disk-group:5239bee8-9297-c091-df17-241a4c197f8d" -Metric iopsSched

#>

    param(

        [Parameter(Mandatory=$true)][String]$Cluster,

        [Parameter][String]$StartTime,

        [Parameter][String]$EndTime,

        [Parameter(Mandatory=$true)][String]$EntityId,

        [Parameter(Mandatory=$true)][String]$Metric

    )

    function Convert-StringToDateTime {

        # Borrowed from https://blogs.technet.microsoft.com/heyscriptingguy/2014/12/19/powertip-convert-string-into-datetime...

        param

        (

        [Parameter(Mandatory = $true)]

        [String] $DateTimeStr

        )

        $DateFormatParts = (Get-Culture).DateTimeFormat.ShortDatePattern -split '/|-|\.'

        $Month_Index = ($DateFormatParts | Select-String -Pattern 'M').LineNumber - 1

        $Day_Index = ($DateFormatParts | Select-String -Pattern 'd').LineNumber - 1

        $Year_Index = ($DateFormatParts | Select-String -Pattern 'y').LineNumber - 1

        $DateTimeParts = $DateTimeStr -split '/|-|\.| '

        $DateTimeParts_LastIndex = $DateTimeParts.Count - 1

        $DateTime = [DateTime] $($DateTimeParts[$Month_Index] + '/' + $DateTimeParts[$Day_Index] + '/' + $DateTimeParts[$Year_Index] + ' ' + $DateTimeParts[3..$DateTimeParts_LastIndex] -join ' ')

        return $DateTime

    }

    $cluster_view = (Get-Cluster -Name $cluster).ExtensionData.MoRef

    $vpm = Get-VSANView -Id "VsanPerformanceManager-vsan-performance-manager"

  #  $start = Convert-StringToDateTime $StartTime

   # $end = Convert-StringToDateTime $EndTime

    $spec = New-Object VMware.Vsan.Views.VsanPerfQuerySpec

    $spec.EntityRefId = $EntityId

    $spec.Labels = @($Metric)

    $spec.StartTime = (Get-Date).AddMinutes(-30)

    #$spec.EndTime = $end

    $vpm.VsanPerfQueryPerf(@($spec),$cluster_view)

}

Method -2

Get-VsanStat -Entity <Cluster_Name> -Start (Get-Date).AddMinutes(-30) -Name VMConsumption.ReadIops

Note: But i am able to retrieve the metrics for vmware using "Get-Stat -Entity <Cluster_Name> -Start (Get-Date).AddMinutes(-30)  -Stat cpu.usage.mhz"

Reply
0 Kudos
0 Replies