5 Replies Latest reply on Aug 12, 2019 1:49 AM by LucD

    The metric counter "disk.usage.average" doesn't exist for entity

    ganapa2000 Hot Shot

      Hi,

       

      I am unable to get the performance details for a VM as getting the below error

       

      $servers=Get-Content ".\servers.txt"

      foreach ($server in $servers)

      {

          $vm=Get-VM $server

          if($? -eq $false)

          {

              continue

          }

          $fileName=".\$server.csv"

          $diskusageaverage=Get-Stat -entity $vm -MaxSamples 168 -Start (Get-Date).AddDays(-1) -IntervalMins 60 -stat "disk.usage.average" | ? { $_.instance -eq "" } | select Entity,Timestamp,Value |Sort-Object Timestamp

          $memusageaverage=Get-Stat -entity $vm -MaxSamples 168 -Start (Get-Date).AddDays(-1) -IntervalMins 60 -stat "mem.usage.average" | ? { $_.instance -eq "" } | select Entity,Timestamp,Value |Sort-Object Timestamp

          $cpuusageaverage=Get-Stat -entity $vm -MaxSamples 168 -Start (Get-Date).AddDays(-1) -IntervalMins 60 -stat "cpu.usage.average" | ? { $_.instance -eq "" } | select Entity,Timestamp,Value |Sort-Object Timestamp

          $netusageaverage=Get-Stat -entity $vm -MaxSamples 168 -Start (Get-Date).AddDays(-1) -IntervalMins 60 -stat "net.usage.average" | ? { $_.instance -eq "" } | select Entity,Timestamp,Value |Sort-Object Timestamp

          Set-Content -Value "ServerName,AVG_CPU_Time,AVG_CPU,AVG_MEM,AVG_disk,AVG_Net" -Path $fileName

          $diskus=0

          for ($i=0;$i -lt $cpuusageaverage.Count ; $i++)

          {

              if (($diskus -lt $diskusageaverage.count) -and ($cpuusageaverage[$i].Timestamp -eq $diskusageaverage[$diskus].Timestamp))

              {

                  Add-Content -Value "$($cpuusageaverage[$i].Entity.Name),$($cpuusageaverage[$i].Timestamp),$($cpuusageaverage[$i].Value),$($memusageaverage[$i].Value),$($diskusageaverage[$diskus].Value),$($netusageaverage[$i].value)" -Path $fileName

                  $diskus++

              }

              else

              {

                      Add-Content -Value "$($cpuusageaverage[$i].Entity.Name),$($cpuusageaverage[$i].Timestamp),$($cpuusageaverage[$i].Value),$($memusageaverage[$i].Value),0,$($netusageaverage[$i].value)" -Path $fileName

              }

          }

      }

      return(0)

       

       

      Error:

       

      Get-Stat : 12-08-2019 12:17:24  Get-Stat            The metric counter "disk.usage.average" doesn't exist for entity

       

      At D:\perf\3.ps1:10 char:23

      + ... sageaverage=Get-Stat -entity $vm -MaxSamples 168 -Start (Get-Date).Ad ...

      +             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo      : ResourceUnavailable: (disk.usage.average:String) [Get-Stat], VimException
      + FullyQualifiedErrorId : Client20_RuntimeDataServiceImpl_CheckUserMetrics_MetricDoesntExist,VMware.VimAutomation.

         ViCore.Cmdlets.Commands.GetViStats

       

      Get-Stat : 12-08-2019 12:17:25  Get-Stat            The metric counter "mem.usage.average" doesn't exist for entity

       

      At D:\perf\3.ps1:11 char:22

      + ... sageaverage=Get-Stat -entity $vm -MaxSamples 168 -Start (Get-Date).Ad ...

      +             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo      : ResourceUnavailable: (mem.usage.average:String) [Get-Stat], VimException
      + FullyQualifiedErrorId : Client20_RuntimeDataServiceImpl_CheckUserMetrics_MetricDoesntExist,VMware.VimAutomation.

         ViCore.Cmdlets.Commands.GetViStats

        • 1. Re: The metric counter "disk.usage.average" doesn't exist for entity
          LucD Guru
          User ModeratorsvExpertCommunity Warriors

          Can you check with Get-StatType if that metric is indeed not present for a specific VM, or for all VMs?

           

          This can also be caused by 1 VM, which perhaps wasn't powered at the $start time, who is missing that metric.

          Can you add the -ErrorAction Slinetly continue parameter on the Get-Stat cmdlet.

           

          Why do you do the Get-Stat four time?

          You can do that in one call, with multiple metrics.

           

          Also, why add the MaxSamples parameter when you use the Start parameter?

          • 2. Re: The metric counter "disk.usage.average" doesn't exist for entity
            ganapa2000 Hot Shot

            LucD,

             

            I am looking to get the CPU, Mem and Disk Max utilization Reports for a day for specific time like 10:00 AM - 10:00 PM (only during Office hours), need help on this. below is the output from

             

            get-vm abc | get-stattype

             

            cpu.usage.average

            cpu.usagemhz.average

            cpu.ready.summation

            mem.usage.average

            mem.swapinRate.average

            mem.swapoutRate.average

            mem.vmmemctl.average

            mem.consumed.average

            mem.overhead.average

            disk.usage.average

            disk.maxTotalLatency.latest

            net.usage.average

            sys.uptime.latest

            disk.used.latest

            disk.provisioned.latest

            disk.unshared.latest

            • 3. Re: The metric counter "disk.usage.average" doesn't exist for entity
              LucD Guru
              Community WarriorsUser ModeratorsvExpert

              Try something like this

               

              $sStat = @{

                Stat = 'cpu.usage.average','mem.usage.average','net.usage.average','disk.usage.average'

                Start = (Get-Date -Hour 10 -Minute 0 -Second 0).AddDays(-1)

                Finish = (Get-Date -Hour 10 -Minute 0 -Second 0).AddDays(-1).AddHours(12)

                Instance = ''

                MaxSamples = [int]::MaxValue

                Entity = Get-VM -Name (Get-Content ".\servers.txt")

                ErrorAction = 'SilentlyContinue'

              }

              Get-Stat @sStat |

              Group-Object -Property {$_.Entity.Name} |

              ForEach-Object -Process {

                 $_.Group | Group-Object -Property Timestamp |

                 ForEach-Object -Process {

                 New-Object -TypeName PSObject -Property ([ordered]@{

                 VM = $_.Group[0].Entity.Name

                 Timestamp = $_.Group[0].Timestamp

                 CpuAvg = ($_.Group | where{$_.MetricId -eq 'cpu.usage.average'}).Value

                 MemAvg = ($_.Group | where{$_.MetricId -eq 'mem.usage.average'}).Value

                 DiskAvg = ($_.Group | where{$_.MetricId -eq 'disk.usage.average'}).Value

                 NetAvg = ($_.Group | where{$_.MetricId -eq 'net.usage.average'}).Value

                 })

                 }

              } | Export-Csv -Path .\report.csv -NoTypeInformation -UseCulture

              • 4. Re: The metric counter "disk.usage.average" doesn't exist for entity
                ganapa2000 Hot Shot

                Thanks LucD,

                 

                This reports shows average, how can I get the maximum details ? when I change from average to maximum, it shows blank (vCenter :Current Statistics Level 1)

                • 5. Re: The metric counter "disk.usage.average" doesn't exist for entity
                  LucD Guru
                  User ModeratorsCommunity WarriorsvExpert

                  The 'maximum' metrics require a higher Statistics Level, namely 4.

                  As you find out in the PerformanceManager documentation.

                  max.png

                   

                  You can, as an alternative, take the maximum value of the averages over a period of time.

                  Don't forget that the Historical Interval 1 (past day) has in any case aggregated the values to 5 minute intervals.

                  See also my PowerCLI & VSphere Statistics – Part 1 – The Basics post.