0 Replies Latest reply on Dec 12, 2014 6:54 AM by sn250170

    Powercli script to retrieve the metrics of the resource pools at particular time interval from vcenter

    sn250170 Lurker

      Hi Team,

       

      I Google and found the below script which will capture the metrics(CPU, Memory) of the each individual host from vcenter, but I need to capture the same metrics at the resource pool level(i.e for each individual resource pool).

       

      Please do needful help and provide me the script which will retrieve the metrics at resource level.

       

      Connect-VIServer <vcneter serve> -User <username> -Password <password>

      $allvms = @()

      $vms = Get-Vm

       

       

      $stats = Get-Stat -Entity $vms -start (get-date).AddDays(-30) -Finish (Get-Date)-MaxSamples 10000 -stat "cpu.usage.average","mem.usage.average"

      $stats | Group-Object -Property Entity | %{

        $vmstat = "" | Select VmName, MemMax, MemAvg, MemMin, CPUMax, CPUAvg, CPUMin

        $vmstat.VmName = $_.name

       

        $cpu = $_.Group | where {$_.MetricId -eq "cpu.usage.average"} | Measure-Object -Property value -Average -Maximum -Minimum

        $mem = $_.Group | where {$_.MetricId -eq "mem.usage.average"} | Measure-Object -Property value -Average -Maximum -Minimum

       

       

        $vmstat.CPUMax = [int]$cpu.Maximum

        $vmstat.CPUAvg = [int]$cpu.Average

        $vmstat.CPUMin = [int]$cpu.Minimum

        $vmstat.MemMax = [int]$mem.Maximum

        $vmstat.MemAvg = [int]$mem.Average

        $vmstat.MemMin = [int]$mem.Minimum

        $allvms += $vmstat

      }

      $allvms | Select VmName, MemMax, MemAvg, MemMin, CPUMax, CPUAvg, CPUMin | Export-Csv "E:\newVMs.csv" -noTypeInformation