1 2 3 4 5 Previous Next 61 Replies Latest reply on Apr 12, 2016 10:15 AM by ggmattingly Go to original post
      • 45. Re: Using PowerCLI to get VM Disk Stats
        AlbertWT Master

        Let us know here on in the new thread if there is any update LucD

        • 46. Re: Using PowerCLI to get VM Disk Stats
          LucD Guru
          Community WarriorsvExpertUser Moderators

          Not sure I understand what kind of update you are expecting ?

          Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
          • 47. Re: Using PowerCLI to get VM Disk Stats
            warnox Enthusiast

            Hi,

             

            I'm seeing some strange results with this and wondering if someone can help. If I run the script below, so without grouping, the results come out as expected, for both VMs.

             

            $metrics = "cpu.usage.average","mem.usage.average","disk.usage.average","disk.maxTotalLatency.latest","net.usage.average"
            $arrVMs = Get-VM Terminator, CCFS01
            $start = (Get-Date).AddDays(-7)
            $stats = Get-Stat -Entity $arrVMs -Stat $metrics -Start $start | fl
            echo $stats
            

            Value        : 0.58

            Timestamp    : 02/03/2016 05:30:00

            MetricId     : cpu.usage.average

            Unit         : %

            Description  : CPU usage as a percentage during the interval

            Entity       : CCFS01

            EntityId     : VirtualMachine-vm-107

            IntervalSecs : 1800

            Instance     :

            Uid          : ...VirtualMachine-vm-107/FloatSample=cpu.usage.average\\635924934000000000/

             

            Value        : 0.83

            Timestamp    : 02/03/2016 05:00:00

            MetricId     : cpu.usage.average

            Unit         : %

            Description  : CPU usage as a percentage during the interval

            Entity       : CCFS01

            EntityId     : VirtualMachine-vm-107

            IntervalSecs : 1800

            Instance     :

            Uid          : ...VirtualMachine=VirtualMachine-vm-107/FloatSample=cpu.usage.average\\635924916000000000/

            If I add a grouping.

             

            $metrics = "cpu.usage.average","mem.usage.average","disk.usage.average","disk.maxTotalLatency.latest","net.usage.average"
            $arrVMs = Get-VM Terminator, CCFS01
            $start = (Get-Date).AddDays(-7)
            $stats = Get-Stat -Entity $arrVMs -Stat $metrics -Start $start
            
            $groups = $stats | Group-Object -Property {$_.Entity, $_.MetricId, $_.Instance}
            
            $report = $groups | % {
                New-Object PSObject -Property @{
                    Description = $_.Group[0].Description
                    Entity = $_.Group[0].Entity
                    MetricId = $_.Group[0].MetricId
                    Timestamp = $_.Group[0].Timestamp
                    Unit = $_.Group[0].Unit
                    Value = [math]::Round(($_.Group | Measure-Object -Property Value -Average).Average, 2)
                }
            }
            echo $report
            

             

            The output is only.

            Value       : 52.34

            Description : CPU usage as a percentage during the interval

            Timestamp   : 08/03/2016 13:00:00

            Entity      : CCFS01

            MetricId    : cpu.usage.average

            Unit        : %

            Any help appreciated.

            • 48. Re: Using PowerCLI to get VM Disk Stats
              LucD Guru
              Community WarriorsvExpertUser Moderators

              I strongly suspect that the difference is in the use of the Instance property.

              For a multi-core CPU there will be three different instances: the aggregate (instance -eq "") and one for each core (instance 0 and 1).

              Same is true for the disk and net metrics (provided you have more than one of these in the VM)

              Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
              • 49. Re: Using PowerCLI to get VM Disk Stats
                warnox Enthusiast

                The instance field was always empty. I tried removing the CPU metrics from the script and grouping only on Entity and MetricID, but still getting the same one line output.

                 

                $metrics = "mem.usage.average","disk.usage.average","disk.maxTotalLatency.latest","net.usage.average"
                $arrVMs = Get-VM Terminator, CCFS01
                $start = (Get-Date).AddDays(-7)
                $stats = Get-Stat -Entity $arrVMs -Stat $metrics -Start $start
                
                $groups = $stats | Group-Object -Property {$_.Entity, $_.MetricId}
                
                $report = $groups | % {
                    New-Object PSObject -Property @{
                        Description = $_.Group[0].Description
                        Entity = $_.Group[0].Entity
                        MetricId = $_.Group[0].MetricId
                        Timestamp = $_.Group[0].Timestamp
                        Unit = $_.Group[0].Unit
                        Value = [math]::Round(($_.Group | Measure-Object -Property Value -Average).Average, 2)
                    }
                }
                
                echo $report
                
                

                Value       : 65.11

                Description : Memory usage as percentage of total configured or available memory

                Timestamp   : 08/03/2016 13:30:00

                Entity      : CCFS01

                MetricId    : mem.usage.average

                Unit        : %

                 

                EDIT: Even if I remove all metrics except mem.usage.average I still get the same result.

                • 50. Re: Using PowerCLI to get VM Disk Stats
                  LucD Guru
                  User ModeratorsvExpertCommunity Warriors

                  How many elements do you get in the $groups variable after the Group-Object line ?

                  Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                  • 51. Re: Using PowerCLI to get VM Disk Stats
                    warnox Enthusiast

                    Just 1 server by the looks of it.

                     

                    Count Name                  Group
                    ----- ----                  -----

                      668 CCFS01 mem.usage.average  {1.8, 1.75, 2.17, 2.06...}

                    • 52. Re: Using PowerCLI to get VM Disk Stats
                      LucD Guru
                      User ModeratorsCommunity WarriorsvExpert

                      But since you group on EntityId and MetricId, there should be more entries.

                      Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                      • 53. Re: Using PowerCLI to get VM Disk Stats
                        warnox Enthusiast

                        Yes exactly, something isn't quite right

                        • 54. Re: Using PowerCLI to get VM Disk Stats
                          LucD Guru
                          Community WarriorsUser ModeratorsvExpert

                          Were these VMs poweredon at the start of he interval you are requesting ?

                          You can do a quick check in the Performance tab of the vSphere or Web Client.

                          Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                          • 55. Re: Using PowerCLI to get VM Disk Stats
                            warnox Enthusiast

                            No, all powered on. Getting the same results regardless of which VM I pick. If you execute the scripts I posted what do you get?

                            • 56. Re: Using PowerCLI to get VM Disk Stats
                              LucD Guru
                              vExpertCommunity WarriorsUser Moderators

                              I get, as expected, 4 objects (one for each metric) per VM

                              Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                              • 57. Re: Using PowerCLI to get VM Disk Stats
                                warnox Enthusiast

                                Interesting.

                                 

                                Which vSphere/PowerCLI version? I'm using 6.0.

                                • 58. Re: Using PowerCLI to get VM Disk Stats
                                  LucD Guru
                                  vExpertUser ModeratorsCommunity Warriors

                                  The test was against vSphere 5.5, and I used PowerCLI 6.0

                                  Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                                  • 59. Re: Using PowerCLI to get VM Disk Stats
                                    warnox Enthusiast

                                    Thanks for your help LucD.

                                     

                                    I took a somewhat different approach but managed to make it work. I've put the solution on my site, http://docs.nzsystems.com/?p=262.