3 Replies Latest reply on Aug 12, 2019 6:10 AM by ganapa2000

    Performance Chart shows blank

    ganapa2000 Hot Shot

      Hi,

       

      I have having issue with plotting data with Performance Chart, please help.

       

      Below scripts, Performance charts shows blank

       

      $chart1 = New-ExcelChart -Title Usage -ChartType BarClustered -Header 'Usage' -XRange 'Usage[Name]' -YRange @('Usage[Mem Usage( % )]','Usage[CPU Usage( % )]')

       

      $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-Excel -Path ".\report.xlsx" -WorkSheetname Usage -TableName Usage -ExcelChartDefinition $chart1 -Show

        • 1. Re: Performance Chart shows blank
          LucD Guru
          vExpertCommunity WarriorsUser Moderators

          When you define the chart, you have to use columnnames (and the worksheetname) to define the X and Y ranges.

          Something like this

           

          $chart1 = New-ExcelChart -Title Usage -ChartType BarClustered -Header 'Usage' -XRange 'Usage[VM]' `

             -YRange @('Usage[CpuAvg]','Usage[MemAvg]') -SeriesHeader @('CpuAvg','MemAvg')

           

          But what exactly do you want to plot?

          Timestamp (X) vs the values (Cpu,Mem,Net,Disk) for each VM?

          Then you will have to reformat the data, you can only have 1 X range

          • 2. Re: Performance Chart shows blank
            LucD Guru
            Community WarriorsUser ModeratorsvExpert

            I suspect this might be more in line of what you are looking for?

             

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

            $yRange = $vms.Name | %{"Usage[$_-CpuAvg]","Usage[$_-MemAvg]"} | Sort-Object

            $headers = $yRange.replace('Usage[','').replace(']','')

            $chart1 = New-ExcelChart -Title Usage -ChartType BarClustered -Header 'Usage' -XRange 'Usage[Timestamp]' `

               -YRange $yRange -SeriesHeader $headers

             

            $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 = $vms

              ErrorAction = 'SilentlyContinue'

            }

            Get-Stat @sStat |

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

            ForEach-Object -Process {

               $obj = [ordered]@{

               Timestamp = $_.Name

               }

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

               ForEach-Object -Process {

               $obj.Add("$($_.Name)-CpuAvg",($_.Group | where{$_.MetricId -eq 'cpu.usage.average'}).Value)

               $obj.Add("$($_.Name)-MemAvg",($_.Group | where{$_.MetricId -eq 'mem.usage.average'}).Value)

               $obj.Add("$($_.Name)-DiskAvg",($_.Group | where{$_.MetricId -eq 'disk.usage.average'}).Value)

               $obj.Add("$($_.Name)-NetAvg",($_.Group | where{$_.MetricId -eq 'net.usage.average'}).Value)

               }

               New-Object -TypeName PSObject -Property $obj

            } | Export-Excel -Path ".\report.xlsx" -WorkSheetname Usage -TableName Usage -ExcelChartDefinition $chart1 -Show -ClearSheet

            • 3. Re: Performance Chart shows blank
              ganapa2000 Hot Shot

              Perfect LucD, This is what I am looking for

               

              Thank you very much.